- 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.pyBot Creation Steps
- Open Telegram, search for @BotFather
- Send /newbot to create new bot
- Get API token
- 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 webhookHandler 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