360 Secure SkillHub
360 安全技能中心

Telegram Bot

提供 Telegram 机器人创建流程与 CLI 脚本用法:用 token 启动 scripts/bot.py,可指定 Python 处理函数文件、Webhook 地址与端口或改用长轮询;支持命令、内联按钮回调、群组管理和消息通知等场景。

dinghaibin
dinghaibin
热度 32.53
最近更新 2026-05-11 17:46:13
分类:开发依赖:代码执行 / 第三方 API / 读写文件应用场景:API 集成 / 自动化脚本 / 代码生成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add telegram-bot-pro
Metadata
name
telegram-bot
description
Create and manage Telegram bots. Use when user wants to build a Telegram bot for notifications, automation, customer support, group management, or interactive commands.

Telegram Bot

Create and manage Telegram bots using the Bot API.

Quick Start

# Get bot token from @BotFather on Telegram
# Create bot.py:
python scripts/bot.py --token YOUR_TOKEN --handler my_handler.py

Bot Creation Steps

  1. Open Telegram, search for @BotFather
  2. Send /newbot to create new bot
  3. Get API token
  4. Configure webhooks or polling

Core Features

  • Commands: /start, /help, /settings
  • Callbacks: Inline buttons, queries
  • Groups: Admin tools, filters
  • Webhooks: Receive updates via HTTP

Script Usage

python scripts/bot.py [OPTIONS]

Options:
  --token TEXT        Bot API token (required)
  --handler PATH      Python handler file
  --webhook-url URL   Webhook endpoint URL
  --port PORT         Webhook server port (default: 8443)
  --poll              Use long polling instead of webhook

Handler Format

# my_handler.py
def handle_update(update, context):
    """Handle incoming updates."""
    if update.message:
        text = update.message.text
        if text == "/start":
            context.bot.send_message(
                chat_id=update.message.chat_id,
                text="Hello! I'm your bot."
            )

Examples

See references/examples.md for:

  • Echo bot
  • Inline keyboard bot
  • Group admin bot
  • Notification bot
  • Weather bot