Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Beniamiiin committed Nov 30, 2023
1 parent e6c6eeb commit e4f3095
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions internal/tg_bot/handlers/access_governance_bot/command_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,28 @@ func (h *accessGovernanceBotCommandHandler) Handle(update tgbotapi.Update) []tgb
telegramUser = callbackQuery.From
}

// if update.ChatMember != nil {
// h.logger.Infow("received NewChatMember", update.ChatMember.NewChatMember)

// if (update.ChatMember.NewChatMember != tgbotapi.ChatMember{}) {
// newChatMember := update.ChatMember.NewChatMember.User
// h.logger.Infow("received NewChatMemberUser", newChatMember)
// user, err := h.userRepository.GetOneByTelegramNickname(newChatMember.UserName)
// if err != nil {
// h.logger.Errorw("failed to get user", "error", err)
// return []tgbotapi.Chattable{}
// }
// h.logger.Infow("received NewChatMember", user)
// user.TelegramID = newChatMember.ID

// _, err = h.userRepository.Update(user)
// if err != nil {
// h.logger.Errorw("failed to update user", "error", err)
// return []tgbotapi.Chattable{}
// }

// return []tgbotapi.Chattable{}
// }
// }
if len(message.NewChatMembers) > 0 {
for _, newChatMember := range message.NewChatMembers {
user, err := h.userRepository.GetOneByTelegramNickname(newChatMember.UserName)
if err != nil {
h.logger.Errorw("failed to get user", "error", err)
continue
}

user.TelegramID = newChatMember.ID

_, err = h.userRepository.Update(user)
if err != nil {
h.logger.Errorw("failed to update user", "error", err)
continue
}
}

return []tgbotapi.Chattable{}
}

if telegramUser.ID != chatID {
h.logger.Infow("received update", "update", update)
h.logger.Infow("received message", "message", message)
return []tgbotapi.Chattable{}
}

Expand Down

0 comments on commit e4f3095

Please sign in to comment.