Код: Выделить всё
### import os from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext from telegram import Bot # Function to handle incoming images def image_handler(update, context): # Your image handling logic here pass # Command handler for /start def start(update, context): update.message.reply_text("Welcome to my realm! Send me an image to get details about the anime depicted.") # Command handler for /help def help(update, context): help_message = """ Available commands: /start - Start the bot /help - Display help message /about - Display information about the bot /random - Get a random anime recommendation """ update.message.reply_text(help_message) # Command handler for /about def about(update, context): about_message = "AnimeBot v1.0\\nCreated by \[Your Name\]" update.message.reply_text(about_message) # Command handler for /random def random_anime(update, context): # Your random anime recommendation logic here pass def main(): # Retrieve the bot token from an environment variable token = os.environ.get('TELEGRAM_BOT_TOKEN') if token is None: print("Error: Please set the TELEGRAM_BOT_TOKEN environment variable.") return # Create a Bot instance with the retrieved token bot = Bot(token=token) # Create an Updater with the Bot instance updater = Updater(bot=bot) # Get the dispatcher to register handlers dispatcher = updater.dispatcher # Register a message handler to handle all messages dispatcher.add_handler(MessageHandler(Filters.photo, image_handler)) # Register command handlers dispatcher.add_handler(CommandHandler("start", start)) dispatcher.add_handler(CommandHandler("help", help)) dispatcher.add_handler(CommandHandler("about", about)) dispatcher.add_handler(CommandHandler("random", random_anime)) # Start the bot updater.start_polling() updater.idle() if \__name_\_ == '\__main_\_': main ()Код: Выделить всё
dispatcher = updater.dispatcher ^^^^^^^^^^^^^^^^^^ AttributeError: 'Updater' object has no attribute 'dispatcher'
Я пытался что-то изменить, но все равно нет работаю, обновил библиотеку и многое другое не могу найти, если сможете найти, пожалуйста, решите и отправьте мне обратно
Подробнее здесь: https://stackoverflow.com/questions/781 ... r-and-more