umputun / tg-spam

Anti-Spam bot for Telegram and anti-spam library
https://tg-spam.umputun.dev
MIT License
214 stars 38 forks source link

Errors occur when filtering spam in the admin channel #129

Closed MissiaL closed 1 month ago

MissiaL commented 1 month ago

Example 1. The administrator sent a message to the channel that only contains a link Example 1

Example 2. The administrator sent a message to the channel that only images Example 2

umputun commented 1 month ago

What are those messages the admin is forwarding? Are they even from the group chat tg-spam is protecting, or just some random forwards? The errors you see are saying those IDs can't even be found in the primary group.

MissiaL commented 1 month ago

These are errors from the main chat, in which the antispam bot works. These errors are specific to images and links only.

MissiaL commented 1 month ago

It seems that this problem may be relevant for all types of messages. Monosnap ‎⁨Спам Осиного Чата ВЛ⁩ 2024-09-27 15-40-49

umputun commented 1 month ago

this is unlikely a bug in the system as others can successfully forward without any problems. My guess would be that something in your configuration prevents access to the db. It is hard to diagnose this without any logs, so all I can do is guesswork here.

I would suggest checking the logs; they may give you a clue.

MissiaL commented 1 month ago

New problem image

tg-spam  | 2024/09/30 08:53:51.798 [DEBUG] {bot/spam.go:205 bot.(*SpamFilter).watch.func2} add file "/srv/data/stop-words.txt" to watcher
tg-spam  | 2024/09/30 08:53:53.490 [INFO]  {bot/spam.go:271 bot.(*SpamFilter).ReloadSamples} loaded samples - spam: 221, ham: 462, excluded tokens: 279, stop-words: 11
tg-spam  | 2024/09/30 08:53:53.688 [INFO]  {app/main.go:591 main.makeSpamLogWriter} logger enabled for /srv/log/tg-spam.log, max size 10M
tg-spam  | 2024/09/30 08:53:53.689 [DEBUG] {app/main.go:282 main.execute} telegram listener config: {group: -1001366657637, idle: 30s, super: [frogges blqpqpu lb_ii Dmitramir easyling Blackey22], admin: -4586408721, testing: [], no-reply: true, suppress: false, dry: false, training: false}
tg-spam  | 2024/09/30 08:53:53.690 [INFO]  {events/listener.go:58 events.(*TelegramListener).Do} start telegram listener for "-1001366657637"
tg-spam  | 2024/09/30 08:53:53.804 [INFO]  {events/listener.go:435 events.(*TelegramListener).updateSupers} added admins, full list of supers: {frogges, blqpqpu, lb_ii, Dmitramir, easyling, Blackey22, life_varshavskaya_admin_bot, PetrAlexeev}
tg-spam  | 2024/09/30 08:53:53.805 [INFO]  {events/listener.go:83 events.(*TelegramListener).Do} admin chat ID: -4586408721
tg-spam  | 2024/09/30 08:53:53.806 [DEBUG] {events/listener.go:107 events.(*TelegramListener).Do} admin handler created, spam forvarding enabled, &{tbAPI:0xc000088140 bot:0xc0001d2820 locator:0xc00021e090 superUsers:[frogges blqpqpu lb_ii Dmitramir easyling Blackey22 life_varshavskaya_admin_bot PetrAlexeev] primChatID:-1001366657637 adminChatID:-4586408721 trainingMode:false softBan:false dry:false warnMsg:You've violated our rules and this is your first and last warning. Further violations will lead to permanent access denial. Stay compliant or face the consequences!}
tg-spam  | 2024/09/30 09:02:58.136 [DEBUG] {events/admin.go:318 events.(*admin).InlineCallbackHandler} unban action activated, chatID: -4586408721, userID: 52337683:231598, orig: "permanently banned {52337683 pijenart Artem Krasheninnikov}\n\nspam detection results\n- stopword: ham, not found\n- images: spam, images without text\n- cas: ham, record not found\n- message length: ham, too short"
tg-spam  | 2024/09/30 09:02:58.136 [DEBUG] {events/admin.go:409 events.(*admin).callbackUnbanConfirmed} unban action activated, chatID: -4586408721, userID: 52337683:231598
tg-spam  | panic: runtime error: slice bounds out of range [2:1]
tg-spam  |
tg-spam  | goroutine 1 [running]:
tg-spam  | github.com/umputun/tg-spam/app/events.(*admin).getCleanMessage(0xc000088140?, {0xc0000b8680, 0xd0})
tg-spam  |      /build/app/events/admin.go:593 +0x231
tg-spam  | github.com/umputun/tg-spam/app/events.(*admin).callbackUnbanConfirmed(0xc0001185b0, 0xc0005e20c0)
tg-spam  |      /build/app/events/admin.go:422 +0x305
tg-spam  | github.com/umputun/tg-spam/app/events.(*admin).InlineCallbackHandler(0xc0001185b0, 0xc0005e20c0)
tg-spam  |      /build/app/events/admin.go:319 +0x365
tg-spam  | github.com/umputun/tg-spam/app/events.(*TelegramListener).Do(0xc0002c2000, {0xe0e7b0, 0xc000070aa0})
tg-spam  |      /build/app/events/listener.go:139 +0x175e
tg-spam  | main.execute({_, _}, {{{0xc00002c00f, 0x2e}, {0xc00002a02f, 0xe}, 0x6fc23ac00, 0x6fc23ac00}, {0xc00002800c, 0xb}, ...})
tg-spam  |      /build/app/main.go:289 +0x1045
tg-spam  | main.main()
tg-spam  |      /build/app/main.go:168 +0x508
tg-spam exited with code 2
tg-spam  | 2024/09/30 09:02:58.767 [DEBUG] {app/main.go:456 main.makeDetector} dynamic spam file: /srv/var/spam-dynamic.txt
tg-spam  | 2024/09/30 09:02:58.767 [DEBUG] {app/main.go:460 main.makeDetector} dynamic ham file: /srv/var/ham-dynamic.txt
tg-spam  | 2024/09/30 09:02:58.773 [DEBUG] {app/main.go:201 main.execute} data db: /srv/var/tg-spam.db
tg-spam  | 2024/09/30 09:02:58.776 [DEBUG] {storage/approved_users.go:62 storage.(*ApprovedUsers).Read} read 302 approved users
tg-spam  | 2024/09/30 09:02:58.780 [DEBUG] {app/main.go:213 main.execute} approved users from: /srv/var/tg-spam.db, loaded: 302
tg-spam  | 2024/09/30 09:02:58.780 [DEBUG] {app/main.go:479 main.makeSpamBot} spam bot config: {SpamSamplesFile:/srv/data/spam-samples.txt HamSamplesFile:/srv/data/ham-samples.txt StopWordsFile:/srv/data/stop-words.txt ExcludedTokensFile:/srv/data/exclude-tokens.txt SpamDynamicFile:/srv/var/spam-dynamic.txt HamDynamicFile:/srv/var/ham-dynamic.txt SpamMsg:this is spam SpamDryMsg:this is spam (dry mode) WatchDelay:5s Dry:false}
tg-spam  | 2024/09/30 09:02:58.780 [DEBUG] {bot/spam.go:221 bot.(*SpamFilter).ReloadSamples} reloading samples
umputun commented 1 month ago

this should be fixed on master version

MissiaL commented 1 month ago

Thanks