gpt4 book ai didi

telegram - 深度链接到 Telegram Bot

转载 作者:行者123 更新时间:2023-12-01 12:03:45 36 4
gpt4 key购买 nike

我有一个简单的用例。当用户点击下面的链接时,

T.me/MycompanynameBot?start=Microsoft



我想向他展示 3 个对应于 Microsoft 内 3 个 Telegram channel 的内嵌按钮。这可能吗?

关键是机器人必须能够从 URL 检索参数。

谢谢你。

最佳答案

是的,可以通过 answerCallbackQuery 检索机器人参数

Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like:
t.me/your_bot?start=XXXX
that open your bot with a parameter.



这是我为您制作的示例:
 {
"ok": true,
"result": [{
"update_id": 89590932,
"message": {
"message_id": 5978,
"from": {
"id": 223110107,
"is_bot": false,
"first_name": "Ğąme",
"last_name": "Ǿver!",
"username": "GameO7er",
"language_code": "en"
},
"chat": {
"id": 223110107,
"first_name": "Ğąme",
"last_name": "Ǿver!",
"username": "GameO7er",
"type": "private"
},
"date": 1579094448,
"text": "/start Microsoft",
"entities": [{
"offset": 0,
"length": 6,
"type": "bot_command"
}]
}
}]
}

如您所见 类型=bot_command 所以你可以解析消息 if (type == "bot_command")并获取文本和子字符串 /start从原始文本或您想做的任何事情。

在许多情况下,我使用参数检测用户,例如,当我想知道谁邀请此用户加入机器人时,我会以这种格式分享链接:

t.me/NameBot?start=ReferUserID



例如 :

t.me/NameBot?start=223110107



是我的 ID,我可以看到我邀请了多少用户加入机器人。

希望有用。

关于telegram - 深度链接到 Telegram Bot ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59731664/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com