From ea51cdda8fd226f18c44a59e6b5d0a9566f1491e Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Sun, 17 Sep 2023 23:06:00 +0700 Subject: [PATCH] add log --- internal/modules/messenger/telegram/telegram.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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, }