telegram-readonly
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTelegram Readonly
Telegram Readonly
Use the local skill script for Telegram reads from the user's personal account.
This skill exists because Telegram Bot API is the wrong tool for reading a real personal account. Use MTProto via Telethon instead.
使用本地 skill 脚本从用户个人账户读取 Telegram 内容。
开发这个 skill 的原因是 Telegram Bot API 并不适合读取真实个人账户的内容,我们改为通过 Telethon 使用 MTProto。
Quick rules
快速规则
- Use this skill only for reads.
- Do not improvise write actions.
- Do not add send/edit/delete logic to the wrapper unless the user explicitly asks.
- Treat the Telethon session like a high-privilege secret.
- Assume unread preservation is best-effort until tested on a real chat.
- 仅将该 skill 用于读取操作。
- 不得随意新增写入操作。
- 除非用户明确要求,否则不得在封装层添加发送/编辑/删除逻辑。
- 将 Telethon 会话视为高权限机密信息。
- 在真实聊天中测试完成前,默认未读状态保留功能为尽力而为模式。
Local setup
本地设置
Prefer the skill-local script and a skill-local virtual environment over any global CLI install.
Prefer saved Telegram config over shell-exported environment variables once setup is complete.
Treat as generated local state, not part of the skill itself.
If the installer drops skill-local dotfiles, the bootstrap script recreates automatically.
.venv.gitignoreBootstrap the local environment:
bash
<skill-path>/scripts/bootstrap_venv.shAfter bootstrap, use:
bash
<skill-path>/scripts/telegram-readonlyIf is missing later, just run the bootstrap script again.
.venvPrimary config path:
bash
~/.config/telegram-readonly/config.jsonRecommended one-time setup:
- Make sure and
api_idare available.api_hash - Run:
bash
<skill-path>/scripts/telegram-readonly authAfter successful login, the config file stores , , and the Telegram session string so future reads do not need exported shell variables.
api_idapi_hash优先使用 skill 本地脚本和 skill 本地虚拟环境,而非任何全局 CLI 安装。
设置完成后,优先使用保存的 Telegram 配置,而非 shell 导出的环境变量。
将 视为生成的本地状态,不属于 skill 本身的一部分。
如果安装程序生成了 skill 本地的点文件,引导脚本会自动重新创建 。
.venv.gitignore引导本地环境:
bash
<skill-path>/scripts/bootstrap_venv.sh引导完成后,使用以下命令:
bash
<skill-path>/scripts/telegram-readonly如果后续 丢失,重新运行引导脚本即可。
.venv主配置路径:
bash
~/.config/telegram-readonly/config.json推荐的一次性设置流程:
- 确保已获取 和
api_id。api_hash - 运行:
bash
<skill-path>/scripts/telegram-readonly auth登录成功后,配置文件会存储 、 和 Telegram 会话字符串,后续读取操作无需再导出 shell 变量。
api_idapi_hashCommands
命令说明
Show built-in help
查看内置帮助
bash
<skill-path>/scripts/telegram-readonly helpbash
<skill-path>/scripts/telegram-readonly helpAuthenticate once
单次身份验证
bash
export TELEGRAM_API_ID='12345678'
export TELEGRAM_API_HASH='your_api_hash'
<skill-path>/scripts/telegram-readonly authbash
export TELEGRAM_API_ID='12345678'
export TELEGRAM_API_HASH='your_api_hash'
<skill-path>/scripts/telegram-readonly authList chats
列出聊天
dialogs --querynameusernametitlepetros skynetbash
<skill-path>/scripts/telegram-readonly dialogs --limit 50dialogs --querynameusernametitlepetros skynetbash
<skill-path>/scripts/telegram-readonly dialogs --limit 50Read recent messages
读取近期消息
bash
<skill-path>/scripts/telegram-readonly messages --chat '@username' --limit 50 --reversebash
<skill-path>/scripts/telegram-readonly messages --chat '@username' --limit 50 --reverseSearch messages
搜索消息
bash
<skill-path>/scripts/telegram-readonly search 'invoice' --limit 50Restrict search to one chat:
bash
<skill-path>/scripts/telegram-readonly search 'deadline' --chat '@username' --limit 50bash
<skill-path>/scripts/telegram-readonly search 'invoice' --limit 50限制搜索范围为单个聊天:
bash
<skill-path>/scripts/telegram-readonly search 'deadline' --chat '@username' --limit 50List recent unread chats
列出近期未读聊天
Default behavior is opinionated: exclude muted and archived chats.
bash
<skill-path>/scripts/telegram-readonly unread-dialogs --limit 10Include muted and/or archived when needed:
bash
<skill-path>/scripts/telegram-readonly unread-dialogs --limit 10 --include-muted --include-archived默认逻辑经过设计:会排除静音和归档的聊天。
bash
<skill-path>/scripts/telegram-readonly unread-dialogs --limit 10如有需要可包含静音和/或归档聊天:
bash
<skill-path>/scripts/telegram-readonly unread-dialogs --limit 10 --include-muted --include-archivedList recent unread DMs only
仅列出近期未读私信
bash
<skill-path>/scripts/telegram-readonly unread-dms --limit 10bash
<skill-path>/scripts/telegram-readonly unread-dms --limit 10Workflow
工作流程
- Read if setup, auth, or unread-state behavior matters.
references/setup-and-safety.md - Ensure the skill-local virtual environment is bootstrapped.
- Ensure Telegram API credentials exist.
- Run once to create the session and write
auth.~/.config/telegram-readonly/config.json - Use ,
dialogs,messages,search, orunread-dialogsas needed.unread-dms - Keep usage narrow and intentional.
- 如果关注设置、身份验证或未读状态行为相关的细节,请先阅读 。
references/setup-and-safety.md - 确保 skill 本地虚拟环境已完成引导。
- 确保已持有 Telegram API 凭证。
- 运行一次 命令创建会话并写入
auth。~/.config/telegram-readonly/config.json - 根据需求使用 、
dialogs、messages、search或unread-dialogs命令。unread-dms - 保持使用场景窄而明确。
Expected outputs
预期输出
The wrapper returns JSON. Parse it instead of relying on fragile text scraping.
Dialog objects include:
is_useris_groupis_channelis_botarchivedmuted- unread counters
封装层返回 JSON 格式内容,请直接解析 JSON,不要依赖脆弱的文本爬取逻辑。
对话对象包含以下字段:
is_useris_groupis_channelis_botarchivedmuted- 未读计数
Files
文件说明
- Package repo:
https://github.com/ropl-btc/telegram-readonly-cli - Launcher:
scripts/telegram-readonly - Python implementation:
scripts/telegram_readonly.py - Local bootstrap:
scripts/bootstrap_venv.sh - Setup notes:
references/setup-and-safety.md - Config storage:
~/.config/telegram-readonly/config.json - is optional fallback only; it is not the preferred long-term setup.
.env - is generated local state and can be recreated with
.venv/.scripts/bootstrap_venv.sh
- 代码仓库:
https://github.com/ropl-btc/telegram-readonly-cli - 启动器:
scripts/telegram-readonly - Python 实现:
scripts/telegram_readonly.py - 本地引导脚本:
scripts/bootstrap_venv.sh - 设置说明:
references/setup-and-safety.md - 配置存储路径:
~/.config/telegram-readonly/config.json - 仅作为可选降级方案,不是推荐的长期设置方式。
.env - 是生成的本地状态,可通过
.venv/重新生成。scripts/bootstrap_venv.sh
When to stop and ask
需要停止并询问的场景
Stop and ask before:
- adding write capabilities
- enabling any background watcher/daemon
- broad exporting of large chat histories
- changing how secrets/session storage works
出现以下操作前请停止并询问用户:
- 新增写入能力
- 启用任何后台监听器/守护进程
- 大量导出大规模聊天历史
- 修改机密/会话存储的实现逻辑