Ban passer-by spammers from Telegram channel comments

ghz 8months ago ⋅ 130 views

Ban passer-by spammers from Telegram channel comments

So there's a channel with comments enabled, and as we know that is implemented via an associated group. Now there's the occasional spammer, and we'd like to ban them. Not a problem via the Windows application as long as the spammer has a @username, but they usually don't.

So enter the Bot API, which has the banChatMember call, sounds good, where you can ban chat members by ID instead of by @username. Your bot needs to be admin in the group, no problem. However, turns out that in order to ban a chat member, he needs to be, well, an actual chat member, not just a passer-by who hassn't joined the group.

So now you'd need to add him to the group first in order to ban him. By the looks of it, a ban is implemented as just a special kind of membership where you can't read and are in solitary confinement (you're the one and only member of the group once you're banned). But how do we add the spammer to the group? We can't do it via the Bot API and his ID because there's no such method as addChatMember. And we can't do it via the application either because he doesn't have a @username.

There are some anti-spam tools available in Telegram, but only once you've reached 200 members.

Is there a solution to this problem short of using the "real" API (probably channels.editBanned), as opposed ot the Bot API?

Answers

Unfortunately, the Telegram Bot API does not provide a direct method for adding users to a group or channel without their consent. This restriction is in place to prevent abuse and maintain user privacy.

If you're dealing with a spammer who doesn't have a username and is not currently a member of the group, it's challenging to directly ban them using the Bot API alone.

Here are a few alternative approaches you might consider:

  1. Report and Remove: If the spammer is posting offensive or inappropriate content, you can report their messages to Telegram. Telegram's moderators may take action against the spammer's account, such as restricting their ability to send messages. Additionally, you can remove any offensive messages manually.

  2. Restrict Group Access: You can adjust the group's privacy settings to restrict who can join the group. For example, you can set the group to "invite only" mode, where only members who have been explicitly invited can join. This can help prevent spammers from joining the group in the first place.

  3. Implement Filters: Telegram provides tools for implementing message filters and anti-spam measures within your group. You can set up rules to automatically delete messages that contain certain keywords or patterns commonly associated with spam.

  4. Utilize Admin Tools: As a group admin, you have access to various admin tools within the Telegram app. You can manually review and approve new members before they join the group, allowing you to screen out potential spammers.

  5. Encourage Reporting: Encourage group members to report any spam or inappropriate behavior they encounter. This can help you identify and address spam-related issues more effectively.

If the spamming activity persists and becomes a significant problem, you may need to consider using the Telegram API directly to access more advanced moderation features, such as the channels.editBanned method you mentioned. However, keep in mind that using the Telegram API requires additional development effort and may have limitations and restrictions of its own.