import logging from telegram import Update from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters, ContextTypes # Enable logging logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO ) logger = logging.getLogger(__name__) # Define a start command handler async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: await update.message.reply_text('Hello! I am your Telegram bot. Send me a message!') # Define an echo message handler async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: user_message = update.message.text await update.message.reply_text(f'You said: {user_message}') # Define a main function to run the bot def main(): # Replace 'YOUR_BOT_TOKEN' with your bot's token from BotFather BOT_TOKEN = '8046464181:AAEhWZa1_xbXFMPSmRGfrkJ4x7PZsGIwpRA' # Create the Application application = ApplicationBuilder().token(BOT_TOKEN).build() # Register command handlers application.add_handler(CommandHandler('start', start)) # Register message handler for echo functionality application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo)) # Run the bot application.run_polling() if __name__ == '__main__': main()