Skip to main content

Simple Interface for Telegram read and listen

Project description

TelegramManager

A Python CLI tool and module for fetching and monitoring Telegram messages from public channels and groups. Built with Telethon for reliable Telegram API integration.

Installation

Install TelegramManager using pip:

pip install .

For development installation:

pip install -e .[dev]

Configuration

Environment Configuration

Create a .env file in your project root directory:

TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_PHONE_NUMBER=+1234567890

The default TelegramManager() constructor automatically loads these environment variables.

Manual Configuration

For programmatic usage without environment files:

from telegram_manager.controller import TelegramManager

tg = TelegramManager(
    api_id=123456,
    api_hash="your_api_hash_here",
    phone_number="+1234567890"
)

Command Line Interface

The tm command provides two primary operations:

Fetch Messages

Retrieve historical messages from a channel or group:

tm fetch <channel> [--min-id <id>] [--limit <n>]

Example:

tm fetch @openai --limit 10

Listen for Messages

Monitor channels for new messages in real-time:

tm listen <channel>

Example:

tm listen "Some Group Chat"

Python API

Basic Usage

from telegram_manager import TelegramManager

# Initialize with environment configuration
tg = TelegramManager()

Fetching Messages

tg.fetch_messages(
    chat_identifier="@somechannel",
    message_processor=lambda m: print(m.id, m.raw_text),
    limit=5
)

Real-time Message Monitoring

tg.listen("@somechannel", message_handler=lambda m: print(f"New: {m.message}"))

Supported Input Formats

TelegramManager accepts multiple channel identifier formats:

  • Telegram URLs: https://t.me/channelname
  • Username format: @channelname
  • Dialog names: "Channel Display Name"

Authentication

  • Session files are created locally to maintain authentication across sessions
  • First-time usage requires verification code entry
  • Authentication state persists between program runs

Requirements

  • Python 3.7 or higher
  • Valid Telegram API credentials
  • Network connectivity for Telegram API access

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegrammanager-0.1.9.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telegrammanager-0.1.9-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file telegrammanager-0.1.9.tar.gz.

File metadata

  • Download URL: telegrammanager-0.1.9.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

Hashes for telegrammanager-0.1.9.tar.gz
Algorithm Hash digest
SHA256 43426c753e4974a6c266a5d1459472b7eea28ba35a2e97bb85ed5b72ff289e1e
MD5 0f1e6a23ea71b010a272e2738bb5db4d
BLAKE2b-256 f5ce92dba897fa5fe2cbaa9c72fcaf661ef0c47d74f4da95712eb3d9a1c98064

See more details on using hashes here.

File details

Details for the file telegrammanager-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for telegrammanager-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d44d8b517665b6b242c07b4420910cce666e7caf15e34f28639573fc015bd4f5
MD5 cf10c2040ef720ff135a8b7dba695692
BLAKE2b-256 4a4ae20bc5099e4d7f722ba437d25928514ac8f9a8bb4efa98507cef13f46232

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page