tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

. #2986

Closed aboaymn closed 3 months ago

aboaymn commented 3 months ago

from telegram import Update from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext

Replace "YOUR_BOT_TOKEN" with your bot's token

TOKEN = "7376417548:AAFUgZlIIFLJu2SCnAHVhE6JSB2aLNRr3xQ"

def start(update: Update, context: CallbackContext) -> None:     update.message.reply_text("Hello! I am an automatic reply bot. Send me any message, and I'll respond with the same text.")

def echo(update: Update, context: CallbackContext) -> None:     update.message.reply_text(update.message.text)

def main() -> None:     updater = Updater(TOKEN)     dispatcher = updater.dispatcher

    # Add /start command handler     dispatcher.add_handler(CommandHandler("start", start))

    # Add message handler     dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, echo))

    # Start the bot     updater.start_polling()

    # Keep the bot alive until manually stopped     updater.idle()

if name == "main":     main() #1869