diff --git a/internal/modules/messenger/telegram/telegram.go b/internal/modules/messenger/telegram/telegram.go index ca39e7b..6d2f507 100644 --- a/internal/modules/messenger/telegram/telegram.go +++ b/internal/modules/messenger/telegram/telegram.go @@ -6,9 +6,8 @@ import ( "log" "strconv" - tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" - "git.3crabs.ru/VLADIMIR/butler/internal/modules/messenger" + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) type messengerTelegram struct { @@ -34,8 +33,15 @@ func NewMessengerTelegram(token string) (messenger.IMessenger, error) { func (m *messengerTelegram) GetMessage(ctx context.Context) (*messenger.Message, error) { tgMsg := <-m.updates + chatID := int64(0) + if tgMsg.Message.Chat != nil { + chatID = tgMsg.Message.Chat.ID + } + if chatID == 0 { + return nil, fmt.Errorf("get chat id error %+v", tgMsg) + } msg := &messenger.Message{ - ChatID: fmt.Sprintf("%d", tgMsg.Message.Chat.ID), + ChatID: fmt.Sprintf("%d", chatID), UserID: tgMsg.Message.From.UserName, Text: tgMsg.Message.Text, }