import threading import asyncio from telegram import Update from telegram.ext import Application, CommandHandler, CallbackContext import time # Function to start the bot and reply with a welcome message async def start(update: Update, context: CallbackContext) -> None: await update.message.reply_text('Hello! I am your bot. How can I help you today?') # Function to handle the /help command async def help_command(update: Update, context: CallbackContext) -> None: await update.message.reply_text('Use /start to get started with the bot.') # Function to run the bot def run_bot(): # Create a new asyncio event loop loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) # Define your bot token token = '7714605375:AAEfd-D1Y1np-HBJ0jOR1vGfyNJD2hloPAc' application = Application.builder().token(token).build() # Add command handlers application.add_handler(CommandHandler("start", start)) application.add_handler(CommandHandler("help", help_command)) # Start polling for updates loop.run_until_complete(application.run_polling()) # Main function to start the bot in a separate thread def main(): # Start the bot in a separate thread bot_thread = threading.Thread(target=run_bot) bot_thread.start() # Now, you can start your web server or any other service that should run concurrently print("Server is running...") while True: time.sleep(1) # Replace with actual server logic (e.g., web server loop) if __name__ == "__main__": main()