admin管理员组文章数量:1122832
I tried to make a bot that downloads files from Telegram channel, but except of good code I don't get files that may be downloaded in my directory. I tried this code:
@bot.message_handler(content_types=['document'])
def main(message):
if message.document.file_name.startswith("schedule"):
print(f"{Fore.GREEN}got this file: {message.document.file_name}")
id = message.document.file_id
info = bot.get_file(id)
downloaded_file = bot.download_file(file_info.file_path)
path = os.path.join(directory, message.document.file_name)
with open(path, 'wb') as channel_file:
channel_file.write(downloaded_file.content)
Is there any mistake that I've made?
本文标签: Is there any way to download files from TGchannel with using telebot python moduleStack Overflow
版权声明:本文标题:Is there any way to download files from TG-channel with using telebot python module? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311492a1934755.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论