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)
- Clone the repository:
git clone https://github.com/reorx/telememo
cd telememo
- 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
- Visit https://my.telegram.org
- Log in with your phone number
- Go to "API development tools"
- Create a new application
- Copy your
api_idandapi_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:
- Enter your phone number (in international format, e.g., +1234567890)
- Enter the verification code sent to your Telegram app
- 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
Full sync re-fetches all messages and overwrites all data columns of existing
rows. If your database was created before columns like webpage (link preview)
or fwd_* (forward source) were added, run it once to backfill them:
telememo -c @channelname sync --full
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.
Metadata
Release files for telememo 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| telememo-0.3.0.tar.gz | 49.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| telememo-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 95.2 kB
Release files / telememo-0.3.0.tar.gz
| Download URL | telememo-0.3.0.tar.gz |
|---|---|
| Size | 49.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a66d3028124dfd50ef3b0481cf2c9ead939bf2ccca6b4ca0f30e49a967932f7
|
|
BLAKE2b-256 checksum How to use checksums |
f7c66809042cdb9eff3903e93b9bf04d6bc692cb65d6ec098fd5a2295c3ddddb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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}
|
Release files / telememo-0.3.0-py3-none-any.whl
| Download URL | telememo-0.3.0-py3-none-any.whl |
|---|---|
| Size | 45.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46904915177c6d8465c096aed90eca8e42b55c1743b634e146932ae38bc2a843
|
|
BLAKE2b-256 checksum How to use checksums |
5a4e6b79d45e4edfdd38fcf715828228d64ba8df4da0524d86fe4ff736221fbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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}
|
Security for telememo 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.