Answer the question
In order to leave comments, you need to log in
How to send files to a telegram channel using a bot?
Hello. I have a telegram bot that creates entries in the channel: publishes a video (more than 50 mb) and screenshots for it. Video uploaded in advance and sent to the bot. I have a script that can send the file_id of this video, respectively, using this id, you can send the file further. The script that sends the video to the channel consists of two parts: The first one allows you to get the id file. The second one, which already creates an entry in the channel. With the help of the return function, I am trying to pass the id file to the second part of the script. pytelegrambotAPI libraries Here is the code:
import telebot
from telebot.types import InputMediaPhoto, InputMediaVideo
bot = telebot.TeleBot('токкен бота')
@bot.message_handler(content_types=['video'])
def command_handle_video(message):
bot.send_message(message.chat.id, message.video.file_id)
return(bot.send_message)
c=chat_id = 'айди канала'
d = open('/home/roman/Изображения/123.png', 'rb')
f = command_handle_video(message)
bot.send_media_group(c,
[InputMediaPhoto(d, caption='описание видео'),
InputMediaVideo(f)])
Answer the question
In order to leave comments, you need to log in
Why not
@bot.message_handler(content_types=['video'])
def command_handle_video(message):
bot.send_message(message.chat.id, message.video.file_id)
d = open('/home/roman/Изображения/123.png', 'rb')
bot.send_media_group('айди канала',
[InputMediaPhoto(d, caption='описание видео'),
InputMediaVideo(message.video.file_id)])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question