So, I know practically nothing about programming, and I used ChatGPT for this bot here. I would really appreaciate some help if you guys can. The lines that the bot gets and answers the questions are in Russian, by the way.
from telegram import Update, Bot
from telegram.ext import Updater, CommandHandler, MessageHandler, CallbackContext
def start(update: Update, context: CallbackContext):
context.bot.send_message(chat_id=update.effective_chat.id, text="Привет, как тебя зовут?")
def process_question(update: Update, context: CallbackContext):
text = update.message.text.lower()
chat_id = update.effective_chat.id
if text == "привет, как тебя зовут?":
context.bot.send_message(chat_id=chat_id, text="Меня зовут Боб, приятно познакомиться!")
elif text == "как прошел твой день?":
context.bot.send_message(chat_id=chat_id, text="Очень даже неплохо, а у тебя?")
elif text == "что ты планируешь делать на выходные?":
context.bot.send_message(chat_id=chat_id, text="Наверное проведу весь день играя в видео игры, а что насчет тебя?")
elif text == "какой твой любимый цвет?":
# Generate a random color here and send the response
context.bot.send_message(chat_id=chat_id, text="Мой любимый цвет - случайный цвет!")
elif text == "какая твоя любимая еда?":
# Generate a random food choice here and send the response
context.bot.send_message(chat_id=chat_id, text="Моя любимая еда - случайный выбор из меню!")
def main():
bot = Bot(token="YOUR_TELEGRAM_TOKEN")
updater = Updater(bot=bot, use_context=True)
dispatcher = updater.dispatcher
# Add handlers for different commands and messages
start_handler = CommandHandler("start", start)
question_handler = MessageHandler(None, process_question)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(question_handler)
updater.start_polling()
updater.idle()
if __name__ == "__main__":
main()
The problem that I get is:
Exception has occurred: TypeError
Updater.__init__() got an unexpected keyword argument 'use_context'
File "C:\Users\archd\Desktop\Bob_Bot.py", line 29, in main
updater = Updater(bot=bot, use_context=True)
File "C:\Users\archd\Desktop\Bob_Bot.py", line 44, in <module>
main()
TypeError: Updater.__init__() got an unexpected keyword argument 'use_context'