Lightweight Telegram Keyword Alert Bot for Personal Use
Preface
I previously used a Telegram keyword alert bot project.
After using it, I felt the functionality was a bit heavy. The original project was designed for multi-user use, where different users follow different keywords and different groups. Therefore, the original project required a database.
I plan to develop a lightweight Telegram keyword alert bot suitable for personal use.
I'll write the code with the help of the powerful GPT.
The first version of the code was generated using the free Claude.
Subsequent code debugging was done using the free M$ Copilot.
Designed Features
Designed Configuration File
Throwing the Feature Description and Configuration File to Claude
Setting Up the Environment
Debugging
1. Verify the code for starting the user and bot
The correct startup result is,
On the first run, the command line will prompt to enter a verification code.
Subsequent runs do not prompt for a verification code.
2. Disable the user's function of processing received new messages,
disable the bot's function of checking the command source,
and verify the code for the bot handling the /start command
The correct result is,
Send the /start command to the bot from any Telegram user, and the bot can receive the /start message and respond
3. Verify the command /list_keywords for querying the keyword list
The correct result is,
It can correctly display the followed keyword list and excluded keyword list from the configuration file
4. Verify the commands for adding and removing keyword lists
The correct result is,
The modifications can be saved to the configuration file
5. Enable the function for the user to handle received new messages
Print debug information on the command line
The correct result is,
New messages can be received, and there is output on the command line
6. Verify the follow keyword list function and the function of sending notification messages to specified users
The correct result is,
Messages containing the keyword will send notifications to the specified user.
Messages not containing the keyword will not send notifications to the specified user.
7. Verify the function of sending notification messages to specified groups
The correct result is,
Messages containing the keyword will send notifications to the specified group.
8. Verify the function of sending notification messages to specified channels
The correct result is,
Messages containing the keyword will send notifications in the specified channel.
9. Verify the exclude keyword list function
The correct result is,
Messages containing the follow keyword and also containing the exclude keyword will not send notifications.
Messages containing the follow keyword and not containing the exclude keyword will send notifications.
10. Verify the block source function
The correct result is,
Receiving messages containing the follow keyword from normal sources will send notifications.
Receiving messages containing the follow keyword from blocked sources will not send notifications.
11. Enable the function for the bot to determine the command source, and verify the function
The correct result is,
Sending a message from a legitimate command source, the bot responds.
Otherwise the bot responds no permission to use.
That's it for the basic functions.
There are some self-righteous optimizations, no need to be verbose here.
Uploaded to GitHub
https://github.com/crazypeace/tg-keyword-monitor-bot
Actual effect
https://t.me/FuckGFWNewbieNeedHelpThe setup tutorial will be available soon. You can follow my blog. :)
https://zelikk.blogspot.com/p/icdyct.html
========












