J-Rios / TLG_JoinCaptchaBot

Telegram Bot to verify if users joining a group are human. The Bot sends an image captcha for each new user and kicks any of them who can't solve the captcha in a specified time.
GNU General Public License v3.0
515 stars 217 forks source link

[Request] Configurable number of fails to Ban on deploy #176

Closed sharuzzaman closed 1 year ago

sharuzzaman commented 1 year ago

Hi,

I run my own instance of JoinCaptchaBot in multiple Telegram groups, which works very well.

But I noticed, most of the bot does not try to join more than 3 times. So, the automatic ban will not work.

Is it possible to have a parameter/customization for the number of fails before the ban happens? I really would like to set it to 1, because in my sampling, 99% of the join is a bot, and only 1 per cent is human. Even if the human got banned, usually they will ask their friend to let me know about the ban, and I will remove it manually. This is not a problem. Banning the bot manually is a problem for me right now.

I just want the JoinCaptchaBot to be more aggressive in banning, thus the request to ban after 1 to N times customization

Thank you.

J-Rios commented 1 year ago

Hello,

I made some changes related to this few days ago, that allows to configure the number of fails to Ban the user through the settings.py file for Bot deployment. However, this commit has not been merge to other branches, neither tested in real groups, so this request is should be currenlty solved but still not available on current Bots. Please, wait until I release a new Bot version (maybe today or tomorrow) with this changes before you get it (it is still in development).

Once I release the new version, I will notify you here.

The new settings for that configurations will be the next ones (one for general captcha modes and other for poll mode):

https://github.com/J-Rios/TLG_JoinCaptchaBot/blob/13f8ec3bfc72d03c7e31420330a9e49002a2ddf7/sources/settings.py#L119-L125

Regards.

J-Rios commented 1 year ago

Change merged in other branches, and everything seems ok. Now you can get latest Bot code and set the "CAPTCHABOT_MAX_FAIL_BAN" and "CAPTCHABOT_MAX_FAIL_BAN_POLL" constants from settings.py file to 1.

Please, give some feedback regarding that when you test it, to see if it is working properly ;)

sharuzzaman commented 1 year ago

I'm going to deploy it now and will update the result later. Thank you in advance

sharuzzaman commented 1 year ago

Got this error message, and the bot failed to ban

Warning: User ‎@RafizaAhmad fail to solve the captcha 1 times. I tried to ban the "User", but due to an unexpected problem (maybe network/server related), I can't do it.

sharuzzaman commented 1 year ago

2022-10-21 04:31:38: [-1001018484308] Captcha reply timed out for user ‎@RafizaAhmad. 2022-10-21 04:31:38: [-1001018484308] 5636155573 join_retries: 1 2022-10-21 04:31:38: [-1001018484308] Captcha not solved, banning ‎@RafizaAhmad (5636155573)... 2022-10-21 04:31:38: [-1001018484308] 'Bot' object has no attribute 'ban_chat_member' 2022-10-21 04:31:38: [-1001018484308] Warning: User ‎@RafizaAhmad fail to solve the captcha 1 times. I tried to ban the "User", but due to an unexpected problem (maybe network/server related), I can't do it. 2022-10-21 04:31:39: [-1001018484308] Removing messages from user ‎@RafizaAhmad... 2022-10-21 04:31:39: [-1001018484308] Kick/Ban process completed

J-Rios commented 1 year ago

'Bot' object has no attribute 'ban_chat_member'

Maybe you were using an old version of the Bot and now that you have update the code, the phthon-telegram-bot framework used is not the expected version. Please, check it, you need to use python-telegram-bot v13.12.

If you have another version, update it through pip using the requirement file:

python3 -m pip install -r TLG_JoinCaptchaBot/requirements.txt
sharuzzaman commented 1 year ago

updated Python packages. continue testing

sharuzzaman commented 1 year ago

there is a bug where when a new user joins, they are restricted to send a message straight away. there is no way for the user to type the captcha answer

photo_2022-10-21_20-46-25

photo_2022-10-21_20-46-20

J-Rios commented 1 year ago

Thanks for reporting, but please create a new GitHub Issue for that bug topic, just to keep everything in order and avoid mixing stuffs, here we are talking about the Ban issue.

Is the Ban issue solved after updating packages?

Regarding that bug, could be only happening in "ASCII" and "hex" mode, but should work ok in "nums" and "math" mode. Maybe related to missing modes here:

https://github.com/J-Rios/TLG_JoinCaptchaBot/blob/bd80f26d6a1e6d15c2ad5ba366f4d5258cc2625a/sources/join_captcha_bot.py#L1024

sharuzzaman commented 1 year ago

yes. the ban issue was solved after updating the packages. so far no issue with the ban. I can say the feature works. I will open a new issue for the missing mode, as you have traced above

closing this issue.

sharuzzaman commented 1 year ago

updated issue #175 with the observation that only nums and math mode is the only mode where user can type their answer, but not hex or ASCII

J-Rios commented 1 year ago

Perfect, thank you!