Search Telegram private chats from the command line.
Project description
telegram_grep
Search Telegram messages from the command line.
By default telegram-grep searches private one-to-one human chats only. It skips
groups, channels, and bot dialogs unless you opt in.
Install
python -m pip install .
For development:
python -m pip install -e '.[dev]'
Authentication
This uses Telegram MTProto through Telethon, not the Bot API. A Telegram bot token cannot search your personal private chats.
Required environment:
export TG_API_ID=123456
export TG_API_HASH=0123456789abcdef0123456789abcdef
Session options:
# Recommended for automation: Telethon StringSession token.
export TG_SESSION='...'
# Or a local session file. Default: ./telegram_grep.session
export TG_SESSION_FILE=/path/to/telegram_grep.session
If neither session option exists, Telethon will create/use telegram_grep.session
and may prompt interactively for login. You can also set TG_PHONE for the first
login.
Usage
Search private human chats:
telegram-grep 'wikimedia commons bot'
Include groups:
telegram-grep --groups 'wikimedia commons bot'
Search only groups:
telegram-grep --groups-only 'wikimedia commons bot'
Include bot private dialogs:
telegram-grep --include-bots 'wikimedia commons bot'
Print JSON Lines:
telegram-grep --json 'wikimedia commons bot'
Show neighboring messages:
telegram-grep --context 2 'wikimedia commons bot'
Related Documentation
- Telethon documentation
- Telethon sessions
- Telegram API development tools
- Telegram MTProto API
- PyPI Trusted Publishing
Publishing
CI publishes to PyPI on every push to main after tests pass.
PyPI must have a Trusted Publisher configured for:
- owner/repository:
vitaly-zdanevich/telegram_grep - workflow:
.github/workflows/ci.yml - environment:
pypi
Versions are derived from Git tags/commits through hatch-vcs, because PyPI
does not allow re-uploading the same version.
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 telegram_grep-0.1.1.tar.gz.
File metadata
- Download URL: telegram_grep-0.1.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
107c06c92acbfdd56c66b5cf1125be3a07ad03e9c9a605d342a0145e4702c25a
|
|
| MD5 |
a15bdd470a05b24e3c277105a682d39e
|
|
| BLAKE2b-256 |
be067d9ba2d67e8f2314d74554a4eab8625461e9e2ad02a1e9b3ce50c064d8fe
|
Provenance
The following attestation bundles were made for telegram_grep-0.1.1.tar.gz:
Publisher:
ci.yml on vitaly-zdanevich/telegram_grep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_grep-0.1.1.tar.gz -
Subject digest:
107c06c92acbfdd56c66b5cf1125be3a07ad03e9c9a605d342a0145e4702c25a - Sigstore transparency entry: 2102333312
- Sigstore integration time:
-
Permalink:
vitaly-zdanevich/telegram_grep@8965627dfb3398530d516c781f005c219ea87595 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vitaly-zdanevich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@8965627dfb3398530d516c781f005c219ea87595 -
Trigger Event:
push
-
Statement type:
File details
Details for the file telegram_grep-0.1.1-py3-none-any.whl.
File metadata
- Download URL: telegram_grep-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c22503765d57f6f7c3d29791912012ccdc99082eed5efc3a1dbc21ef08c13b35
|
|
| MD5 |
c3eab4054048acd214a0d8111de3375c
|
|
| BLAKE2b-256 |
1e182c942a2b311e5da1646a8c0979a1aa6c7336c6254a198d5edb76eaf1189b
|
Provenance
The following attestation bundles were made for telegram_grep-0.1.1-py3-none-any.whl:
Publisher:
ci.yml on vitaly-zdanevich/telegram_grep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
telegram_grep-0.1.1-py3-none-any.whl -
Subject digest:
c22503765d57f6f7c3d29791912012ccdc99082eed5efc3a1dbc21ef08c13b35 - Sigstore transparency entry: 2102334028
- Sigstore integration time:
-
Permalink:
vitaly-zdanevich/telegram_grep@8965627dfb3398530d516c781f005c219ea87595 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vitaly-zdanevich
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@8965627dfb3398530d516c781f005c219ea87595 -
Trigger Event:
push
-
Statement type: