add log
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Владимир Фёдоров 2023-09-17 23:06:00 +07:00
parent 284221c0f7
commit ea51cdda8f
1 changed files with 9 additions and 3 deletions

View File

@ -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,
}