From b4bdcb95a8a3e2917512c72e91d2d1a2453c4777 Mon Sep 17 00:00:00 2001 From: Umputun Date: Sat, 16 Dec 2023 13:20:54 -0600 Subject: [PATCH] use chat id directly for ban from forwarded messages --- app/events/events.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/events/events.go b/app/events/events.go index 73939216..96425b7a 100644 --- a/app/events/events.go +++ b/app/events/events.go @@ -183,7 +183,7 @@ func (l *TelegramListener) procEvents(update tbapi.Update) error { // message from admin chat if l.isAdminChat(fromChat, msg.From.Username) { - if err := l.adminChatMsgHandler(update, fromChat); err != nil { + if err := l.adminChatMsgHandler(update); err != nil { log.Printf("[WARN] failed to process admin chat message: %v", err) } return nil @@ -243,8 +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 { +func (l *TelegramListener) adminChatMsgHandler(update tbapi.Update) error { shrink := func(inp string, max int) string { if utf8.RuneCountInString(inp) <= max { return inp