When entering this code
def main() -> None:
update_queue = queue.Queue()
bot_token = "token"
bot = Bot(token=bot_token)
updater = Updater(
bot=bot,
update_queue=update_queue
)
conv_handler = ConversationHandler(
entry_points=[CommandHandler('book', book_appointment)],
states={
NAME: [MessageHandler(filters.TEXT & (~filters.COMMAND), book)],
PHONE: [MessageHandler(filters.TEXT & (~filters.COMMAND), phone)],
EMAIL: [MessageHandler(filters.TEXT & (~filters.COMMAND), email)],
ISSUE: [MessageHandler(filters.TEXT & (~filters.COMMAND), issue)],
TIME: [MessageHandler(filters.TEXT & (~filters.COMMAND), time)],
},
fallbacks=[CommandHandler('start', start)],
)
updater.add_handler(conv_handler)
updater.add_handler(CommandHandler("info", info))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()`
an error is issued - Updater' object has no attribute 'add_handler
All necessary libraries were imported correctly: from telegram import Update, Inline Keyboard Button, InlineKeyboardMarkup from telegram.text import Updater, Command Handler, CallbackContext, CallbackQueryHandler, ConversationHandler, MessageHandler, filters import queue from telegram import Bot
, downloaded the latest version of python-telegram-bot
How can I fix this problem?
add_handler
is an attribute of telegram.Update
(not telegram.text.Updater
). For v20 of the library please use this wiki to familiarize yourself with the new Updater (it is in telegram.ext.Updater
)