简体   繁体   English

如何使用电报 api 发送文件?

[英]How to send file with telegram api?

I am creating telegram bot, and I need to send a file from my telegam bot to another telegram chat.我正在创建电报机器人,我需要将一个文件从我的电报机器人发送到另一个电报聊天。 Now I am trying to make it with such request https://api.telegram.org/bot%s/sendDocument?chat_id=%s&document=%s I am setting full link to my document like this C:\Users\User_Name\IdeaProjects\Project_name\src\main\resources\files When I am tryin to send this request, it's like not sending, and I am not reciving a message in another chat.现在我正在尝试使用这样的请求https://api.telegram.org/bot%s/sendDocument?chat_id=%s&document=%s我正在设置到我的文档的完整链接,例如 C:\Users\User_Name\ IdeaProjects\Project_name\src\main\resources\files 当我试图发送这个请求时,就像没有发送一样,我也没有在另一个聊天中收到消息。 Could you help me to resolve this propblem?你能帮我解决这个问题吗?

Please use some libs for doing these.请使用一些库来执行这些操作。 example: telethon, pyrogram, ptb.例如:电视节目、热图、ptb。

you can use client.send_file(entity, file) if you are using telethon.如果您使用的是 Telethon,则可以使用client.send_file(entity, file)

You may have to download file before sending if its not transload.如果文件未转载,您可能需要在发送前下载文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM