← 返回
沟通协作 Key

Telegram Autopilot

Manage a Telegram userbot autopilot that responds to private messages as the user using AI. Use when the user wants to set up auto-replies on their personal...
管理 Telegram 用户机器人的 AI 自动回复功能,以用户身份自动响应私信。适用于为个人账号设置自动回复。
shor73
沟通协作 clawhub v1.1.1 1 版本 99843.8 Key: 需要
★ 0
Stars
📥 639
下载
💾 8
安装
1
版本
#latest

概述

Telegram Autopilot

> Source: https://github.com/Shor73/telegram-autopilot

> Author: @Shor73

> License: MIT

AI-powered autopilot for personal Telegram accounts. Responds to private messages as the user when they're unavailable.

Prerequisites

  • Python 3.10+
  • Telethon: pip3 install telethon
  • Telegram API credentials (api_id + api_hash from https://my.telegram.org)
  • An Anthropic API key (for AI responses)

Setup

1. Get Telegram API Credentials

Direct the user to https://my.telegram.org → API Development Tools → create app.

They need: API ID (number) and API Hash (string).

2. Login Flow

Telegram login requires: phone → OTP code → optional 2FA password.

Critical: OTP codes expire in ~60 seconds. Minimize latency:

  • Use a file-based code exchange (script polls a file every 200ms)
  • Or serve a simple web form on a local port for instant code entry
  • Never rely on chat round-trip for code delivery — too slow

Run scripts/setup.py with the user's credentials. It handles:

  1. Requesting the OTP code
  2. Waiting for code via file (enter_code.txt)
  3. 2FA password if needed
  4. Saving the session file
python3 scripts/setup.py --api-id 12345 --api-hash "abc123" --phone "+1234567890"

The session file (.session) persists auth — login is one-time only.

3. Configure Contacts

Edit config.json to define allowed contacts:

{
  "contacts": {
    "username": {
      "name": "Display Name",
      "id": 123456789,
      "tone": "friendly",
      "language": "en"
    }
  },
  "ai": {
    "provider": "anthropic",
    "model": "claude-sonnet-4-6",
    "api_key": "sk-ant-...",
    "max_tokens": 300
  },
  "owner": {
    "name": "Owner Name",
    "bio": "Brief description for the AI persona",
    "telegram_id": 123456789
  },
  "notifications": {
    "bot_token": "optional-bot-token-for-notifications",
    "chat_id": "optional-chat-id"
  }
}

4. Start Autopilot

python3 scripts/autopilot.py --config config.json --session session_name

Features

Auto-Reply

  • Responds only to allowed contacts in private chats
  • Marks messages as read before replying (natural behavior)
  • Simulates typing delay proportional to response length
  • Maintains conversation history for context

AI Persona

  • System prompt configurable per-contact (tone, language)
  • Never invents facts — says "I'll check and get back to you" for unknowns
  • Never reveals it's AI

Notifications

  • Forwards received messages to owner via Telegram bot
  • Forwards sent replies for monitoring

Paid Media (Channels Only)

Telegram paid media (inputMediaPaidMedia) only works in channels, not private chats.

To send paid media:

  1. Create a private channel
  2. Post media with InputMediaPaidMedia(stars_amount=N, extended_media=[...])
  3. Generate invite link and send to recipient
python3 scripts/send_paid_media.py --session session_name --target username --photo /path/to/photo.jpg --stars 1

Management Commands

Stop autopilot: kill the process or send SIGTERM.

Add/remove contacts: edit config.json and restart.

Architecture

telegram-autopilot/
├── SKILL.md
├── scripts/
│   ├── setup.py          — Login flow (OTP + 2FA)
│   ├── autopilot.py      — Main event loop
│   ├── send_paid_media.py — Paid media via channel
│   └── code_server.py    — Web form for fast OTP entry
└── references/
    └── telegram-auth.md  — Telegram auth flow documentation

Required Credentials

SecretPurposeWhere used
---------
Telegram API ID + HashMTProto client authsetup.py, autopilot.py
Phone number + 2FAAccount login (one-time)setup.py
AI API keyResponse generationautopilot.py
Bot token (optional)Owner notificationsautopilot.py

All secrets are stored in config.jsonnever commit this file.

Security & Ethics

  • Session security: The .session file grants full access to the account. Protect it like a password.
  • Transparency: The AI is instructed to be honest if directly asked whether it's AI.
  • OTP server: code_server.py binds to 127.0.0.1 (localhost only). Never expose it to the network.
  • Notifications: The skill can forward messages to the owner via bot. Ensure you control the bot token and chat_id.
  • Rate limits: Telegram may restrict accounts with aggressive automation. The autopilot uses natural delays.
  • One session at a time: Only one process can use a session file. Stop autopilot before running other scripts.
  • Platform policies: Using a userbot to auto-reply may violate Telegram ToS. Use at your own risk.

版本历史

共 1 个版本

  • v1.1.1 当前
    2026-03-19 09:04 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

communication-collaboration

imap-smtp-email

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

Gmail

byungkyu
Gmail API 集成,托管 OAuth,支持读取、发送和管理邮件、线程、标签及草稿,适用于需要与 Gmail 交互的场景。
★ 72 📥 37,734
communication-collaboration

Slack

steipete
当需要通过 slack 工具从 Clawdbot 控制 Slack 时使用,包括在频道或私信中回复消息或置顶/取消置顶项目。
★ 157 📥 47,685