Typeerror When Initializing Updater in Python-Telegram-Bot

Hello guys i am trying to make a telegram bot but i got an error in token line :

Traceback (most recent call last):
  File "C:\Users\Mustafa\Desktop\Telegram bot\my_telegram_bot.py", line 32, in <module>
    main()
  File "C:\Users\Mustafa\Desktop\Telegram bot\my_telegram_bot.py", line 21, in main
    updater = Updater(token='64xxxxxxxxxxxxxxxxxxxFmQM', use_context=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Updater.__init__() got an unexpected keyword argument 'token'
import os
from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, CallbackContext
import telegram.ext.filters as filters
from pytube import YouTube

def start(update: Update, context: CallbackContext) -> None:
    update.message.reply_text('Send me a YouTube link with /download to get the video.')

def download_video(update: Update, context: CallbackContext) -> None:
    url = context.args[0]
    yt = YouTube(url)
    video = yt.streams.get_highest_resolution()
    video.download()
    filename = f"{yt.title}.mp4"
    os.rename(video.default_filename, filename)
    update.message.reply_document(document=open(filename, 'rb'))
    os.remove(filename)

def main() -> None:
    updater = Updater(token='646XXXXXXXXXXXXXXXXXXXXXXXXXmQM', use_context=True)
    dispatcher = updater.dispatcher

    dispatcher.add_handler(CommandHandler('start', start))
    dispatcher.add_handler(CommandHandler('download', download_video, pass_args=True))
    dispatcher.add_handler(MessageHandler(Filters.TEXT & ~Filters.COMMAND, start))

    updater.start_polling()
    updater.idle()

if __name__ == '__main__':
    main()

I have tried to update the python_telegram_bot and also i heard there are many changes in 20.5 update but idk where to locate it so i hope someone just help me fix the code to make it work .

2
Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article