answerGuestQuery
响应访客查询——访客模式 (Bot API 10.0)。
返回值: 调用成功时返回 SentGuestMessage。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
guest_query_id | String | 是 | 访客查询 ID |
result | InlineQueryResult | 是 | InlineQueryResult JSON 对象——要发送的消息 |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/answerGuestQuery" \
-H "Content-Type: application/json" \
-d '{
"guest_query_id": "GUEST_QUERY_ID",
"result": {
"type": "article",
"id": "1",
"title": "Hello",
"input_message_content": {
"message_text": "Hello!"
}
}
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/answerGuestQuery",
json={
"guest_query_id": "GUEST_QUERY_ID",
"result": {
"type": "article",
"id": "1",
"title": "Hello",
"input_message_content": {
"message_text": "Hello!"
}
}
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/answerGuestQuery`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"guest_query_id": "GUEST_QUERY_ID",
"result": {
"type": "article",
"id": "1",
"title": "Hello",
"input_message_content": {
"message_text": "Hello!"
}
}
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
answerCallbackQuery响应回调查询。answerInlineQuery响应内联查询。answerWebAppQuery发送 Web App 交互结果。answerChatJoinRequestQuery响应聊天加入请求查询 (Bot API 10.1)。sendChatJoinRequestWebApp为聊天加入请求查询显示 Mini App (Bot API 10.1)。