A Python bot that monitors a Telegram supergroup for specific keywords and notifies the admin when they appear in recent messages.
- Connects to Telegram using python-telegram-bot.
- Monitors the last messages in a specified supergroup.
- Checks for predefined watch words.
- Sends a notification to the admin when a keyword is found.
- Python 3.8+
- python-telegram-bot
Install dependencies via pip:
pip install python-telegram-bot --upgrade- Clone the repository:
git clone https://github.com/your-username/telegram-watchword-bot.git
cd telegram-watchword-bot- Create a
.envfile in the project root with the following variables:
BOT_TOKEN=your_bot_token_here
ADMIN_USER_ID=your_telegram_user_id- Update the
GROUP_CHAT_IDandWATCH_WORDSin the script as needed:
GROUP_CHAT_ID = # Supergroup ID
WATCH_WORDS = [""]Run the bot script:
python telegram_watchword_bot.py- The bot checks the most recent messages in the group.
- If any message contains a watch word, a notification is sent to the admin.
- Designed to be run periodically or via a scheduler.
- Ensure the bot has permission to read messages in the target group.
- Watch words are case-insensitive.
- You can adjust the number of recent messages to check via the
limitparameter inget_chat_history.
This project is licensed under the MIT License.