umputun / tg-spam

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

Images only check ignores the whitelist #167

Open dsent opened 3 weeks ago

dsent commented 3 weeks ago

After enabling the images only check, we noticed that normal users, who were already in the white list, were banned by the bot after sending images without text. I believe this to be unintended behavior.

umputun commented 2 weeks ago

From the code, I don't see how this is even possible. The check for approved users happens before any other checks are reached, including the image-only check (a part of the meta checks).

https://github.com/umputun/tg-spam/blob/fd75fc789e09ff89b93567d7aa934d2e77bd6bda/lib/tgspam/detector.go#L120-L120

Are you sure you have not set ParanoidMode (check all messages, env: 'PARANOID', cli: '--paranoid')? The other way to have the check invoked for active users is by setting FIRST_MESSAGES_COUNT, which is by default 1 ("number of first messages to check").

dsent commented 1 week ago

I was able to reproduce. If you're okay with that, I can forward the logs to you privately (they contain some sensitive data). But my user was indeed banned by the bot while being in the whitelist (and, in fact, remaining in the whitelist after the ban).

dsent commented 1 week ago

And the reasons for the ban were: image

umputun commented 1 week ago

I was able to reproduce. If you're okay with that, I can forward the logs to you privately (they contain some sensitive data). But my user was indeed banned by the bot while being in the whitelist (and, in fact, remaining in the whitelist after the ban).

sure, send it over. also configuration (docker compose or cli params) may help to reproduce it locally

umputun commented 1 week ago

should be fine on master, pls give it a try. the PR #177 explains what the issue was.

umputun commented 1 week ago

By the way, thanks for providing details and pushing the issue, which was real.