Skip to content

Commit

Permalink
fix id of chat on forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Dec 16, 2023
1 parent 410b997 commit 6bfb64d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func (l *TelegramListener) procEvents(update tbapi.Update) error {

// adminChatMsgHandler handles messages received on admin chat. This is usually forwarded spam failed
// to be detected by the bot. We need to update spam filter with this message and ban the user.
// Note: fromChat is the chat ID of the chat where the message was received, i.e. the admin chat ID.
func (l *TelegramListener) adminChatMsgHandler(update tbapi.Update, fromChat int64) error {

Check warning on line 247 in app/events/events.go

View workflow job for this annotation

GitHub Actions / build

unused-parameter: parameter 'fromChat' seems to be unused, consider removing or renaming it as _ (revive)

Check warning on line 247 in app/events/events.go

View workflow job for this annotation

GitHub Actions / build

unused-parameter: parameter 'fromChat' seems to be unused, consider removing or renaming it as _ (revive)
shrink := func(inp string, max int) string {
if utf8.RuneCountInString(inp) <= max {
Expand Down Expand Up @@ -286,7 +287,7 @@ func (l *TelegramListener) adminChatMsgHandler(update tbapi.Update, fromChat int
}
log.Printf("[INFO] message %d deleted", info.msgID)

if err := l.banUserOrChannel(bot.PermanentBanDuration, fromChat, info.userID, 0); err != nil {
if err := l.banUserOrChannel(bot.PermanentBanDuration, l.chatID, info.userID, 0); err != nil {
return fmt.Errorf("failed to ban user %d: %w", info.userID, err)
}
log.Printf("[INFO] user %q (%d) banned", update.Message.ForwardSenderName, info.userID)
Expand Down

0 comments on commit 6bfb64d

Please sign in to comment.