当用户上传图片时,仅从 Telegram 机器人收到 'text'
Receive only 'text' from Telegram bot when a user uploads an image
我为 Telegram 机器人设置了一个 AWS Lambda webhook。常规消息会正确传递给事件,但是当用户上传图像时,只有“文本会传递给事件”。可能是什么问题?
Screenshot of the received data.
def hello(event, context):
try:
data = json.loads(event["body"])
originalBody = str(data)
message = str(data["message"]["text"])
chat_id = data["message"]["chat"]["id"]
first_name = data["message"]["chat"]["first_name"]
print(data)
response = "Please /start, {}".format(first_name)
if "start" in message:
response = "Hello {}".format(first_name)
#data = {"text": response.encode("utf8"), "chat_id": chat_id}
data = {"text": "heyyyy!", "chat_id": chat_id}
url = BASE_URL + "/sendMessage"
requests.post(url, data)
requests.post(url, originalBody)
except Exception as e:
print(e)
return {"statusCode": 200}
刚刚以错误的方式访问了变量。 "text"只是钥匙的名字,在有照片的活动中没有找到。
我为 Telegram 机器人设置了一个 AWS Lambda webhook。常规消息会正确传递给事件,但是当用户上传图像时,只有“文本会传递给事件”。可能是什么问题?
Screenshot of the received data.
def hello(event, context):
try:
data = json.loads(event["body"])
originalBody = str(data)
message = str(data["message"]["text"])
chat_id = data["message"]["chat"]["id"]
first_name = data["message"]["chat"]["first_name"]
print(data)
response = "Please /start, {}".format(first_name)
if "start" in message:
response = "Hello {}".format(first_name)
#data = {"text": response.encode("utf8"), "chat_id": chat_id}
data = {"text": "heyyyy!", "chat_id": chat_id}
url = BASE_URL + "/sendMessage"
requests.post(url, data)
requests.post(url, originalBody)
except Exception as e:
print(e)
return {"statusCode": 200}
刚刚以错误的方式访问了变量。 "text"只是钥匙的名字,在有照片的活动中没有找到。