【发布时间】:2018-04-06 19:41:54
【问题描述】:
Result after google [请参阅从磁盘发布图像文件]
In[2]: from telegram import Bot
In[3]: bot = Bot(token)
In[4]: update = bot.get_updates()[0]
In[5]: update
Out[5]: <telegram.update.Update at 0x1a295c18>
In[6]: chat_id = update["message"]["chat"]["id"]
In[7]: bot.send_photo(chat_id=chat_id, photo=open("test.jpg", "rb"))
Traceback (most recent call last):
File "<ipython-input-9-4c19142e0fd3>", line 1, in <module>
bot.send_photo(chat_id=chat_id, photo=open("test.jpg", "rb"))
File "C:\Users\Cheung\Anaconda3\lib\site-packages\telegram\bot.py", line 60, in decorator
result = func(self, *args, **kwargs)
File "C:\Users\Cheung\Anaconda3\lib\site-packages\telegram\bot.py", line 85, in decorator
result = self._request.post(url, data, timeout=kwargs.get('timeout'))
File "C:\Users\Cheung\Anaconda3\lib\site-packages\telegram\utils\request.py", line 265, in post
'POST', url, body=data.to_form(), headers=data.headers, **urlopen_kwargs)
File "C:\Users\Cheung\Anaconda3\lib\site-packages\telegram\utils\request.py", line 196, in _request_wrapper
raise NetworkError('urllib3 HTTPError {0}'.format(error))
NetworkError: urllib3 HTTPError ('Connection aborted.', timeout('The write operation timed out',))
为什么这不起作用?
也许我应该使用其他方式来获取file_id?但是我怎么得到它呢?
【问题讨论】:
-
不要发布代码/错误的图像。请编辑您的问题并将代码和错误回溯粘贴为纯文本。
标签: python bots telegram python-telegram-bot