Simple Interface for Telegram read and listen
Project description
TelegramManager
A simple CLI and Python module to fetch or listen to Telegram messages from public channels or groups. Built with Telethon, with plug-and-play configuration support.
📦 Installation
pip install .
# or for development
pip install -e .[dev]
⚙️ Configuration (Recommended)
Create a .env file in your project root:
TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_PHONE_NUMBER=+1234567890
The default TelegramManager() uses this automatically via a Config wrapper.
🔐 Manual Credential Usage (Alternative)
If you prefer not to use a .env file or Config, instantiate the class manually:
from telegram_manager.controller import TelegramManager
tg = TelegramManager(
api_id=123456,
api_hash="your_api_hash_here",
phone_number="+1234567890"
)
This is useful for scripting, testing, or dynamic environments.
🚀 CLI Usage
Once installed, you can run the tm CLI command:
🔍 Fetch Messages
tm fetch <channel> [--min-id <id>] [--limit <n>]
Example:
tm fetch @openai --limit 10
👂 Listen for Messages
tm listen <channel>
Example:
tm listen "Some Group Chat"
🧩 Python Module Usage
🔧 Initialization
from telegram_manager import TelegramManager
tg = TelegramManager() # Uses .env Config automatically
Or manually, as described in the previous section.
📥 Fetch Messages
tg.fetch_messages(
chat_identifier="@somechannel",
message_processor=lambda m: print(m.id, m.text),
limit=5
)
📡 Listen for Live Messages
tg.listen("@somechannel", message_handler=lambda m: print(f"New: {m.message}"))
📝 Notes
- Accepts URLs (
https://t.me/...), usernames (@...), or dialog names. - A
sessionfile is created locally to persist login across runs. - First-time authentication may prompt for a verification code.
👤 Author
Christian Pojoni 📧 christian.pojoni@gmail.com
📄 License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telegrammanager-0.1.4.tar.gz.
File metadata
- Download URL: telegrammanager-0.1.4.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe2d7ba0f48a5ba0520bf2257602b0e21012422ef5ad927f7fce02147adce631
|
|
| MD5 |
40225041afd9a900d50bd02a9cbd8a22
|
|
| BLAKE2b-256 |
01e97f5168566416b62af96cd09640fe317e7bfcf8df05e1420d868b3bc8496c
|
File details
Details for the file telegrammanager-0.1.4-py3-none-any.whl.
File metadata
- Download URL: telegrammanager-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20ad2e748da4c7d26fb0bdd1bb376bea307f00f1c8922f862383c3fc8c9dc254
|
|
| MD5 |
3dc6ea70b68d3e9162e6160f05028bdb
|
|
| BLAKE2b-256 |
f67480bf5ffaa74b0f65a5df5e2cc6a4b262bf80b1e99f1050003beb335f0d89
|