This tool monitors specified Telegram channels for messages that contain certain keywords and forwards them to a private channel. It's built using Python and Telethon, a Telegram client library.
- Monitors multiple channels.
- Searches for messages with specified keywords.
- Forwards matching messages to a private channel.
Before you can use this tool, you need to set up a few things:
- Python 3.8+ (Tested on 3.10+)
- Telethon Library
- A Telegram API key and API Hash
- A Telegram Bot
- A Private Telegram Channel
Download and install Python from python.org.
- Login to your Telegram account at Telegram Core.
- Go to
API development tools
and fill out the form. - You will get an
api_id
andapi_hash
which are needed for the tool.
- Open Telegram and search for BotFather.
- Send
/newbot
and follow the instructions to create your bot. - Copy the token provided by BotFather.
- Create a new channel in Telegram.
- Switch the channel's privacy to private in the channel settings.
- Add your bot as an administrator to the channel.
The script uses several files for configuration:
-
credentials.json
: Automatically created if not present. It stores API keys, bot token, and private channel ID. -
keywords.txt
: Contains keywords to monitor. Supports special modifiers for dynamic matching:*
at the end allows up to three additional characters.**
allows up to six additional characters.#
at the start includes numeric characters (up to three).##
includes numeric characters (up to six).
Note: Separate keywords using commas. Keywords can span multiple lines for readability; newlines are ignored.
-
channels.txt
: List of channel usernames (the part aftert.me/
) to monitor -
Separate channel names with commas, and feel free to list them across multiple lines for better readability. Newlines between names are ignored.
Note: Ensure you have joined any channel you wish to monitor.
keywords.txt
hello*, world**, #123, ##123456, #or_any_combination**
channels.txt
python, daily_news, target3, target4
Execute the script:
python streaming_overseer.py
- If not yet saved, the script will ask for your API ID, API hash, phone number, username, and bot token.
- The script listens for new messages in the specified channels (You need to have joined the channels you intend to monitor).
- If a message contains any of the specified keywords, it is forwarded to the private channel.
- The script sends a startup message to the private channel when it begins monitoring.
- Use Ctrl+C to safely shut down the monitoring tool.