tgsearch
Search Telegram from the CLI — discover public channels by keyword or search messages within a channel. Use when the user wants to find Telegram channels, look up posts/messages in a channel, or do Te
Files3
View on GitHubSKILL.mdskills/utils/tgsearch/SKILL.md
GitHubtgsearch
CLI for Telegram search, built on Telethon (MTProto user API — not the Bot API).
Setup
pip install telethon- Set
TG_API_IDandTG_API_HASHin the environment — get them at https://my.telegram.org (API Development Tools). - First run prompts for phone number + login code; the session is cached in
tgsearch.sessionafterwards.
Usage
Run the script in this skill's directory (tgsearch.py):
python3 tgsearch.py find "osint" # discover public channels by keyword
python3 tgsearch.py find "osint" -n 50 # more results
python3 tgsearch.py grep @channelname "cve" # search messages within a channel
python3 tgsearch.py grep @channelname "cve" -n 100
Output of find: @username members title per line. Output of grep: date first-100-chars-of-message per line.
Notes
finduses Telegram's contacts search — the same discovery the apps use. There is no API for a true global search of all public channels; results are what Telegram returns for the account.grepsearches message text server-side in a single channel the account can see (public channels work without joining).- Rate limits apply: keep
-nmodest and avoid rapid repeated calls.