← 返回
沟通协作 Key 中文

Telegram History

Fetch Telegram chat message history via MTProto user API (Telethon). Use when needing to read old messages from any Telegram chat, group, or forum topic that...
通过 MTProto 用户 API(Telethon)获取 Telegram 聊天记录。适用于需要读取任意 Telegram 聊天、群组或论坛话题的旧消息。
rhlsthrm
沟通协作 clawhub v1.1.0 1 版本 99881 Key: 需要
★ 1
Stars
📥 2,499
下载
💾 39
安装
1
版本
#latest

概述

Telegram History

Fetch message history from any Telegram chat using MTProto (Telethon). The Bot API cannot read chat history — this skill uses the user API instead.

Setup

1. Install Telethon

pip3 install telethon

2. Get API credentials

Go to https://my.telegram.org/apps and create an app. Save credentials in the skill directory:

cat > <skill-dir>/api_credentials.json << 'EOF'
{"api_id": YOUR_API_ID, "api_hash": "YOUR_API_HASH"}
EOF

3. Login (one-time)

All paths below are relative to the skill directory.

# Step 1: Request a login code (sent to your Telegram app)
python3 scripts/login.py send +1234567890

# Output: Code sent! phone_code_hash: abc123
# Output: Run: python3 login.py verify +1234567890 <code> abc123

# Step 2: Verify with the code you received
# IMPORTANT: Do NOT send the code via Telegram — Telegram detects shared codes and blocks login.
# Use a file, another messenger, or run the command directly in terminal.
python3 scripts/login.py verify +1234567890 <CODE> <PHONE_CODE_HASH>

# If 2FA is enabled, append your password:
python3 scripts/login.py verify +1234567890 <CODE> <PHONE_CODE_HASH> <2FA_PASSWORD>

# Check login status:
python3 scripts/login.py check +1234567890

Session persists in session/ — no need to re-login after initial setup.

Usage

# Fetch last 50 messages from a chat
python3 scripts/tg_history.py history <chat_id> --limit 50

# Fetch from a forum topic
python3 scripts/tg_history.py history <chat_id> --topic <topic_id> --limit 30

# JSON output
python3 scripts/tg_history.py history <chat_id> --json

# Paginate (messages before a specific ID)
python3 scripts/tg_history.py history <chat_id> --offset-id <msg_id> --limit 50

Notes

  • Group chat IDs use -100 prefix (e.g., -1001234567890)
  • Forum topic IDs = the thread/topic message ID
  • Sender names are resolved automatically
  • All paths (session, credentials) are resolved relative to the skill directory — works regardless of install location

版本历史

共 1 个版本

  • v1.1.0 当前
    2026-03-28 20:17 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

communication-collaboration

Himalaya

lamelas
{"answer":"通过IMAP/SMTP管理邮件的CLI。可在终端使用 `himalaya` 收发、回复、转发、搜索及整理邮件。支持多账户与MML(MIME元语言)编写邮件。"}
★ 68 📥 45,629
communication-collaboration

imap-smtp-email

gzlicanyi
使用IMAP/SMTP读取和发送邮件;检查新/未读邮件、获取内容、搜索邮箱、标记已读/未读、发送带附件的邮件。支持...
★ 114 📥 52,470
ai-intelligence

Swap and bridge across 35+ chains with LI.FI

rhlsthrm
基于LI.FI协议的跨链代币兑换与桥接服务,支持获取报价、执行转账、追踪进度,跨35+区块链组合DeFi操作。
★ 2 📥 1,180