Skip to main content

Telememo

Telememo is a Python CLI tool to dump Telegram channel messages to a local SQLite database for easy searching and archival.

Features

  • Dump all messages from Telegram channels to SQLite
  • Search messages by text content
  • Incremental sync to fetch only new messages
  • Built with modern Python async/await
  • Lightweight and easy to use

Requirements

  • Python 3.10 or higher
  • Telegram API credentials (API ID and API hash from https://my.telegram.org)
  • Your Telegram account (phone number) for authentication

Installation

Install from PyPI:

pip install telememo

Or as an isolated CLI tool with uv:

uv tool install telememo

From source (development)

  1. Clone the repository:
git clone https://github.com/reorx/telememo
cd telememo
  1. Install in editable mode:
pip install -e .

For development with testing tools:

pip install -e ".[dev]"

Configuration

Create a configuration file at ~/.config/telememo/config.py:

mkdir -p ~/.config/telememo
cp config.example.py ~/.config/telememo/config.py

Edit ~/.config/telememo/config.py with your credentials:

# Telegram API credentials (get from https://my.telegram.org)
TELEGRAM_API_ID = 12345678
TELEGRAM_API_HASH = "your_api_hash_here"

# Your phone number (optional, will be prompted if not set)
PHONE = "+1234567890"

# Default channel to use when -c/--channel-name is not specified
DEFAULT_CHANNEL = "example_channel"

# Optional: Configure multiple channels
CHANNELS = {
    "tech_news": {
        "id": "@technews",
        "description": "Technology news channel"
    },
}

Getting Telegram API Credentials

  1. Visit https://my.telegram.org
  2. Log in with your phone number
  3. Go to "API development tools"
  4. Create a new application
  5. Copy your api_id and api_hash

Authentication

Important: Telememo uses user authentication, not bot authentication, because Telegram bots cannot access historical channel messages.

When you run the CLI for the first time, you'll be prompted to:

  1. Enter your phone number (in international format, e.g., +1234567890)
  2. Enter the verification code sent to your Telegram app
  3. Optionally enter your 2FA password if enabled

Your session will be saved locally in ~/.local/share/telememo/telethon.session so you won't need to authenticate again. This session file is shared across all channels.

Usage

Dump channel messages

Dump all messages from a channel:

telememo -c @channelname dump-messages

Or use the default channel from config:

telememo dump-messages

Dump with a limit:

telememo -c @channelname dump-messages --limit 100

Sync new messages

Fetch only new messages since last sync:

telememo -c @channelname sync

Show channel information

telememo -c @channelname info

Search messages

Search within a specific channel:

telememo -c @channelname search "search term" --limit 20

Project Structure

telememo/
├── telememo/
│   ├── __init__.py
│   ├── types.py      # Pydantic data models
│   ├── db.py         # Database operations (Peewee ORM)
│   ├── telegram.py   # Telegram client wrapper (Telethon)
│   ├── core.py       # Business logic & scraper
│   └── cli.py        # CLI commands (Click)
├── tests/
│   ├── conftest.py
│   └── test_integration.py
├── pyproject.toml
├── claude.md
└── README.md

Development

Running Tests

Run integration tests:

pytest tests/

Run with verbose output:

pytest -v tests/

Run specific test:

pytest tests/test_integration.py::test_get_channel_info_and_messages -v

Development Guidelines

See claude.md for detailed development guidelines and architecture principles.

Tech Stack

  • Telethon: Telegram MTProto API client
  • Peewee: Lightweight SQLite ORM
  • Click: CLI framework
  • Pydantic: Data validation
  • pytest: Testing framework

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Download files

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

Source Distribution

telememo-0.2.0.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

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

telememo-0.2.0-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file telememo-0.2.0.tar.gz.

File metadata

  • Download URL: telememo-0.2.0.tar.gz
  • Upload date:
  • Size: 48.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for telememo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d3c256ed058254ca4dbe15f229a35f2d0ebbecc3a72d0832898530099b1284d0
MD5 8a593fb68bd78f972df764894fa2af64
BLAKE2b-256 559396052d1957ce26204a81098416ceebcdfbd6130fefc2ebb9d9b860f24716

See more details on using hashes here.

File details

Details for the file telememo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: telememo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 45.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for telememo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcbadd54248ec734265bfde1cb4c2dbcb210439ae1420503b345f4a29dcd01dc
MD5 755c64012f4db1efec9419343af29b14
BLAKE2b-256 db022ebd2090498f4bfab715ea0d4fe1c4ee8564de59af2e8c2c474b86210705

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page