Telegram Bot“找不到聊天" [英] Telegram Bot "chat not found"
本文介绍了Telegram Bot“找不到聊天"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Python 中有以下代码可以从机器人向自己发送消息.
I have the following code in Python to send a message to myself from a bot.
import requests
token = '123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI'
method = 'sendMessage'
myuserid = 1949275XX
response = requests.post(
url='https://api.telegram.org/bot{0}/{1}'.format(token, method),
data={'chat_id': myuserid, 'text': 'hello friend'}
).json()
print(response)
但这会返回 {'description': 'Bad Request: chat not found', 'error_code': 400, 'ok': False}
我做错了什么?我通过将 /getid
发送到 @myidbot
获得了 myuserid
并且我从 @BotFather
What am I doing wrong? I got myuserid
by sending /getid
to @myidbot
and I got my token from @BotFather
推荐答案
正如@maak 所指出的,您需要先向机器人发送消息,然后机器人才能向您发送消息.
As @maak pointed out, you need to first send a message to the bot before the bot can send messages to you.
这篇关于Telegram Bot“找不到聊天"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文