import os from telegram import Update from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext # Get token from environment variable TOKEN = "7465639568:AAGX2th7mPd-_Ih1J4JLOZ-MzUDDBuce2Ss" def start(update: Update, context: CallbackContext): update.message.reply_text("Hello! I'm a test bot hosted on Hugging Face Spaces!") def echo(update: Update, context: CallbackContext): update.message.reply_text(f"You said: {update.message.text}") def main(): # Initialize the Updater with your bot token updater = Updater(TOKEN, use_context=True) dispatcher = updater.dispatcher # Add handlers dispatcher.add_handler(CommandHandler("start", start)) dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, echo)) # Start long polling updater.start_polling() updater.idle() # Block until you press Ctrl+C if __name__ == "__main__": main()