N
N
neuro4live2021-03-03 19:19:19
Python
neuro4live, 2021-03-03 19:19:19

How to find out the original file_name in telegram?

Welcome all! We need a bot, to which if we send a video, it will send a file_id and file_name in response. I figured out the id file, but when I try to get a hire file, Python gives me the following error:
/usr/bin/python3.8 "/home/roman/PycharmProjects/uznaem file_id/main.py"
Traceback (most recent call last):
File "/home/roman/PycharmProjects/uznaem file_id/main.py", line 21, in
bot.polling(none_stop=True)
File "/home/roman/.local/lib/python3.8/site-packages/telebot /__init__.py", line 485, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "/home/roman/.local/lib/python3.8/site-packages/telebot/__init__.py", line 544, in __threaded_polling
raise e
File "/home/roman/.local/lib/python3.8/site-packages/telebot/__init__.py", line 507, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/home/roman/.local/lib /python3.8/site-packages/telebot/util.py", line 117, in raise_exceptions
raise self.exception_info
File "/home/roman/.local/lib/python3.8/site-packages/telebot/util.py ", line 69, in run
task(*args, **kwargs)
File "/home/roman/PycharmProjects/uznaem file_id/main.py", line 13, in command_handle_video
bot.send_message(message.chat.id, message. video.file_name)
AttributeError: 'Video' object has no attribute 'file_name'

Process finished with exit code 1

And you can get anything in response, even video resolution and file size, but file_name does not want to.
Here is the code

import telebot

bot = telebot.TeleBot('токкен бота, думаю он вам не нужен))')

@bot.message_handler(content_types=['text'])
def repeat_all_message(message):
  print(message.text)
  bot.send_message(message.chat.id,message.text)

@bot.message_handler(content_types=['video'])
def command_handle_video(message):
  bot.send_message(message.chat.id, message.video.file_id)
  bot.send_message(message.chat.id, message.video.file_name)






if __name__ == '__main__':
  bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question