umputun / tg-spam

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

OnlyIfBanned flag for unbanChatMember telegram API method #27

Closed slawiko closed 11 months ago

slawiko commented 11 months ago

Addresses #12

Adds --telegram.preserve-unbanned flag for avoiding situation when user is removed from group after unban. Also updates docs accordingly.

Telegram API docs for reference.

umputun commented 11 months ago

Two things:

slawiko commented 11 months ago

about flag inverting - my bad, did few iterations of renaming and confused myself. Thanks for fixing

about the unban process not working - again my bad, it is not working indeed. I investigated why, and the reason is that user is not actually banned, but restricted. Previously, without only_if_banned flag, we did not see issues with unbanning, because user was removed from the group together with its restrictions.

Of course we can get rid of that flag and everything will work as expected before. But also we could really ban user instead of restricting it (I prepared PR). This way the preserve-unbanned flag will not be needed, although I would keep only_if_banned in unban API call just for improbable situation when bot will mess up some IDs and innocent user is removed from the group. Anyways let's continue discussion in the PR, if you think it is needed