Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

TypeError when initializing Updater in python-telegram-bot

Writer Mia Lopez

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 Related questions 1 python-telegram-bot keyboard doesn't appear 430 Telegram Bot - how to get a group chat id? 1 AttributeError: module 'telegram.ext.filters' has no attribute 'text' Related questions 1 python-telegram-bot keyboard doesn't appear 430 Telegram Bot - how to get a group chat id? 1 AttributeError: module 'telegram.ext.filters' has no attribute 'text' 892 "TypeError: a bytes-like object is required, not 'str'" when handling file content in Python 3 0 Telegram bot - Updater Load 2 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.