Ошибка в коде бота для тг на python
Вот ошибка:
Traceback (most recent call last):
File "C:\Users\goldn\porn.py", line 38, in <module>
main()
File "C:\Users\goldn\porn.py", line 28, in main
updater = Updater(TOKEN)
^^^^^^^^^^^^^^
TypeError: Updater.__init__() missing 1 required positional argument: 'update_queue'
Вот код:
import os
import requests
from telegram.ext import Updater, CommandHandler
TOKEN = 'token'
def start(bot, update):
update.message.reply_text('Привет! Отправь мне ссылку на видео, чтобы я скачал его.')
def downloadvideo(bot, update, args):
chat_id = update.message.chat_id
url = args[0] # Получаем ссылку на видео из сообщения
try:
response = requests.get(url, stream=True)
filename = url.split('/')[-1] # Извлекаем имя файла из ссылки
with open(filename, 'wb') as videofile:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
videofile.write(chunk)
update.message.reply_text('Видео успешно скачано!')
bot.send_video(chat_id=chat_id, video=open(filename, 'rb'))
os.remove(filename) # Удаляем файл после отправки
except Exception as e:
update.message.reply_text('Произошла ошибка при скачивании видео.')
def main():
updater = Updater(TOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler('start', start))
dp.add_handler(CommandHandler('download', downloadvideo, pass_args=True))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()