Telegram Anti-Ad Bot: Human Verification on First Message
There are many advertising bots that pass verification when first joining a group, and then stay silent. Until one night they start sending ad messages.
After some debugging and solving a few small issues.
So I thought, if we add a human verification when a group member sends their first message, would that greatly improve this issue?
Let's use GPT to develop it.
Implement such a telegram bot
When a group member sends a message, detect whether they are a verified member
If not a verified member, then:
Mute the member
Forward the message to the repository channel for saving
Delete the message from the group
Send a message in the group to remind that member to complete the human verification in a private chat with the bot
After passing the human verification, forward the saved message from the repository channel to the group just now.
The telegram userid of verified members is saved in a valid.yaml file.
For management convenience, username and fullname are saved synchronously with the userid
However, username and fullname are not used as judgment criteria, they are just for human convenience in managing this file.
The human verification process is that the bot asks a question, and the user replies with text.
The amount of generated code is much more than the previous project, reaching over 500 lines!
Reading a brand new project requires so much more brainpower!
Moreover, the pset design from the previous project is not utilized. Hmm, not good.
So here's what we do, first copy and paste all the code from the previous project in. Then write out the just-mentioned requirements, and let GPT generate.
This way, the generated code only adds some new logic. It's much less difficult to read.
Committed to Github
For deployment instructions, see the project Readme
========
Effect
========
Postscript
The pset definition of this project is exactly the same as the previous project.
So these two projects can be placed in the same directory to run, this way they can share the .py files under the pset directory for generating question-answer pairs.
root@rn-TEST:~/tg-antispam-bot# tree
.
|-- logs
| |-- tg-join-group-exam-bot-0_20251006.log
| `-- tg-send-msg-exam-bot-0_20251006.log
|-- pset
| |-- blog.py
| |-- rss.py
| `-- youtube.py
|-- tg-join-group-exam-bot-0.py
|-- tg-send-msg-exam-bot-0.py
`-- valid.yaml
========
