我如何发送一张照片聊天,而不压缩,作为一个文件。当我用当前方法实现它时,文件将作为没有扩展名的文档发送。
bot = TeleBot("API")
@bot.message_handler(content_types=['text'])
def send(message):
with open("5.jpg", "rb") as file:
f = file.read()
bot.send_document(message.chat.id, document=f)
bot.polling(True)发布于 2022-06-02 09:16:37
当你做的时候
f = file.read()结合document=f,电报将接收文件的内容。
若要发送带有原始文件名的文件,请从file传递open()变量
with open("/tmp/ccatt.jpeg", "rb") as file:
bot.send_document(123456789, document=file)

https://stackoverflow.com/questions/72464746
复制相似问题