skip to Main Content

Please help me fix this bug in my Python code.

Error type: Update tool.init() got an unexpected argument of the keyword ‘token’

Code:

# Telegram Bot API
from telegram.text import Updater

updater = Updater(token='my bot token', context_user=True)
dispatcher = updater.dispatcher

I’ve tried different versions of the code, I can’t figure out what the error is.

2

Answers


    • The Updater class should be imported from telegram.ext, not text
    • For older python-bot-api versions, remove the token= part
    • Looking at the Updater() source code, there is no option called context_user, so remove that too

    from telegram.ext import Updater
    
    updater = Updater('my bot token')
    
    Login or Signup to reply.
  1. telegram-bot==3.2.0 package it working fine and passing token as following

    from telegram import Updater
    updater = Updater(token='token')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search