Skip to main content

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

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


Download files

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

Source Distribution

telegram_grep-0.1.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

telegram_grep-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

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

Hashes for telegram_grep-0.1.1.tar.gz
Algorithm Hash digest
SHA256 107c06c92acbfdd56c66b5cf1125be3a07ad03e9c9a605d342a0145e4702c25a
MD5 a15bdd470a05b24e3c277105a682d39e
BLAKE2b-256 be067d9ba2d67e8f2314d74554a4eab8625461e9e2ad02a1e9b3ce50c064d8fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for telegram_grep-0.1.1.tar.gz:

Publisher: ci.yml on vitaly-zdanevich/telegram_grep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for telegram_grep-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c22503765d57f6f7c3d29791912012ccdc99082eed5efc3a1dbc21ef08c13b35
MD5 c3eab4054048acd214a0d8111de3375c
BLAKE2b-256 1e182c942a2b311e5da1646a8c0979a1aa6c7336c6254a198d5edb76eaf1189b

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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