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
534 stars 219 forks source link

[Request] Support for topics #177

Closed ippocratis closed 1 year ago

ippocratis commented 2 years ago

Telegram recently added "topics" for groups larger than 200 members

https://telegram.org/blog/topics-in-groups-collectible-usernames

Also a related admin permission added Caled "manage topics"

Bot can't handle new user joins with the new features enabled

J-Rios commented 2 years ago

Hi,

I am aware of this, topics is a really nice feature for Telegram, however it has broken a lot of Bots due them still doesn't support it...

Current status for joincaptchabot: It works in standard groups as usually, but it doesn't work on groups configured to use topics. The reason for that is Telegram Server expecting message from the Bot to be send to a specified topic, so standard messages send without any topic ID is discarted and doesn't even shown in the group. The good thing for this is that joincaptchabot detects that something went wrong at sending the message and it stop the captcha process, so the new members that joins group are not kicked/banned without a reason.

The support for topics requires that the Bot know wich topic must use to send the captcha messages...

A. One approach is to create a new Bot command that must be used by an Admin inside a topic chat, this tells the Bot to use that topic chat for the captcha process. Something like /topic_captcha command. The the Bot can store the topic ID from that command and use it for captchas of that group.

B. Another approach is to request an Owner/Admin of the group to give the "Manage Topic" permission the joincaptchabot. Once the Bot has this permission, it should creates a topic named "Captcha Verification" and set it as the topic to send the captcha messages.

Any other approach are welcome...

Regarding why I don't start any implementation for this yet: joincaptchabot use python-telegram-bot framework to handle all Telegram communications, and it still doesn't support the topic stuffs from Telegram Bot API, so we need to wait until that is supported there. Otherwise we should need to rewrite everything related to Telegram communication to make the API request by our way, and that doesn't make too much sense in my opinion, it is better to wait for that support and keep using a well known and tested framework instead of creating one by ourself.

Regards :)

ippocratis commented 2 years ago

Thanks for the reply and explanation. Best practice is to wait for python-telegram-bot . Then any implementation is good for us users. its up yo you. Cheers

J-Rios commented 1 year ago

Latest Telegram Update added a default topic named "General" to all groups configured to work with topics, and now any message that doesn't specify any topic will appear on that topic, messages like new users joins or Bots default messages.

This solves the issue of joincaptchabot not working in topics groups. Now the Bot captcha message will appear in that "General" topic and the captcha process works again.

However, users who haven't updated their Telegram App won't be able to see that topic, and that means they will be kicked out of groups without realizing they have to solve a captcha. So I recommend disabling joincaptchabot in groups with topics for a few days until all users have updated their Telegram App.