How redianmarku/telegram-autoforwarder works
Project type and purpose
• This is a small, open-source, command-line Python tool (“Telegram Autoforwarder”) whose sole purpose is to forward messages containing specified keywords from one Telegram chat (group or channel) to another.
• Key indicators: single Python script (TelegramForwarder.py), Telethon dependency, CLI‐style setup and usage in the README.
File structure
• Top-level files only:
• .gitignore – standard VCS ignore rules
• README.md – project description & usage instructions
• requirements.txt – Telethon (and any other libraries)
• TelegramForwarder.py – main script implementing all logic
• No separate src or tests directories: the entire functionality lives in one script.
• No build or deployment config—runs directly via python TelegramForwarder.py.
README for additional insights
• Uses Telethon library to connect to the Telegram API.
• Authentication via user’s API ID, hash, and phone number.
• Two modes: list available chats; start the forwarding loop.
• Core workflow: fetch messages → filter by keywords → forward matched messages.
a. Main components
1. User/Operator (CLI)
2. Authentication Module (stores API credentials)
3. Telethon Client
4. Telegram API Endpoints
5. Message Fetcher
6. Keyword Filter Engine
7. Forwarder Module
8. (Optional) Logger/Console Output
b. Relationships & interactions
• User interacts with the CLI to configure and start forwarding.
• CLI passes credentials to Authentication Module, which initializes the Telethon Client.
• Telethon Client opens a persistent connection to the Telegram API.
• Message Fetcher polls or listens for new messages in the source chat via Telethon.
• Each message passes through the Keyword Filter Engine.
• Filter Engine, on match, invokes the Forwarder Module, which uses Telethon to send the message to the destination chat.
• All steps can log status/errors to console or a file.
c. Architectural patterns/design principles
• Single-process, event-loop pattern: Telethon’s async event loop continuously monitors for incoming messages.
• Modular separation of concerns (even within one file): authentication, fetching, filtering, forwarding.
d. Key technologies/frameworks
• Python 3.x
• Telethon (Telegram API client library)