python-3.x - 向电报机器人发送消息,错误:{'ok': False, 'error_code': 400, 'description': 'Bad Request: chat not found'}
问题描述
import requests
def telegram_bot_sendtext(bot_message):
bot_token = '101XXXXXX:AAF50Nh75K0jf0cKN16SFpTqge2gijqMsAUV'
bot_chatID = 'XXXXXXXX'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
response = requests.get(send_text)
return response.json()
test = telegram_bot_sendtext("Testing Telegram bot")
print(test)
我不明白为什么这不起作用,当我在我的网络浏览器中使用我的机器人令牌来获取更新时,它工作得很好。我立即尝试使用相同的凭据以及我的 chat_id 向同一个机器人发送消息,但我收到了该错误。
解决方案
推荐阅读
- javascript - 如何将多个元素移动到数组的开头?
- c# - 无法建立连接,因为目标机器活动拒绝它?
- javascript - 如何以较小的增量滚动水平引导选项卡
- python - 如何在 Python 中调试 iOS Selenium 测试
- reactjs - useState 更新状态值,但将旧值作为参数传递给函数
- ios - 是否可以快速从 CoreData 中获取数组?
- python - 是否可以从程序外部覆盖方法?
- django - Django REST 框架:没有 PK 的 URL
- c# - 如何修复 Asp.net-mvc 网站(使用文化和 .resx 文件)突然改变语言?
- javascript - Swiper滑块+动画CSS