Telepot Bot:HTTP 400响应

时间:2019-09-30 05:40:49

标签: python raspberry-pi telegram telepot

我试图在我的Raspberry Pi上安装Telepot,并编写了一个python脚本,该脚本仅按时通过电报向我发送了一条消息(使用crontab)。使用此脚本,一切都可以正常工作(令牌和CHAT-ID当然是我在此代码中刚刚替换的真实ID)

import telepot

bot = telepot.Bot('#TOKEN')
bot.sendMessage('#CHAT-ID', 'message')

此后,我尝试从另一个python文件中获取ID字符串,使用这两个脚本我遇到了错误。

values.py:

chat_id = 'ChatID'
Token = 'TOKEN'

message.py:

   import telepot
   import values

   with open("values.py", "r") as valuesFile:
   chat_id, Token = valuesFile.readlines()

   bot = telepot.Bot('TOKEN')
   bot.sendMessage(chat_id, 'message')

这是我收到的错误消息:

telepot.exception.BadHTTPResponse: (200, u'<html>\r\n<head><title>400 Bad Request</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<hr><center>nginx/1.16.1</center>\r\n</body>\r\n</html>\r\n', <urllib3.response.HTTPResponse object at 0x76bc1850>)

0 个答案:

没有答案