如何使用 python 机器人将本地 html 文件发送到 Telegram

How can I send local html file to Telegram with python bot

这是我的代码

file_address = './charts/candle_chart.html'
response = bot.sendDocument(chat_id=chat_id, document=file_address, timeout=timeout)

但我得到异常 host not found 错误

telegram 认为这个文件在网上

谁能帮帮我!

电报机器人的文档说:

The document argument can be either a file_id, an URL or a file from disk: open(filename, 'rb')

所以一定是这样的:

html_file = open('./charts/candle_chart.html', 'rb')
response = bot.sendDocument(chat_id=chat_id, document=html_file, timeout=timeout)

有关详细信息,请参阅 documentation