电报机器人API:用户回答民意调查后,如何停止在Webhook中获取消息?

发布于 2025-02-07 06:16:39 字数 548 浏览 1 评论 0原文

我已经通过机器人在私人聊天中发送了民意调查。民意调查看起来不错。但是当我回答时 - 电报服务器重复将消息发送到Web挂钩:

{“ Update_id”:199522750, “ poll”:{“ id”:“ 5276163750276104310”,“问题”:“问题?”,“选项”:[{“ text”:“ test1”,“ pofter_count”:0},{“ text”,“ text”:“ test2 “,” pofter_count“:1},{“ text”:“ test3”,“ pofter_count”:0}],“ total_voter_count”:1,“ is_closed”:is_closed“:false”:false,“ IS_ANOMNONDOUS”:iS_ANTOMNONDOUS“:true,true,type” type“ type”:“常规“,”允许_multiple_answers”:false}}

webhook每分钟收到它。我已经用民意调查删除了消息。如何停止此消息?我猜一些对服务器的“确认”答案。

我需要收到一次结果,然后停止民意调查。这是与Bot的私人聊天,没有其他人会回答民意调查。

I have send poll by my bot in private chat with a bot. Poll appeared fine. But when I answer it - telegram server repeat sending message to web hook:

{"update_id":199522750,
"poll":{"id":"5276163750276104310","question":"Question?","options":[{"text":"test1","voter_count":0},{"text":"test2","voter_count":1},{"text":"test3","voter_count":0}],"total_voter_count":1,"is_closed":false,"is_anonymous":true,"type":"regular","allows_multiple_answers":false}}

Webhook receives it every minute. I have deleted message with poll. How to stop this messages? Some "confirm" answer to server needed I guess.

I need to receive result once, and stop a poll. This is private chat with bot, nobody else will answer a poll.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘落散花 2025-02-14 06:16:39

需要存储来自SendPoll返回数据的轮询ID,消息ID,聊天ID的聊天ID。
然后在Webhook呼叫中stoppoll并处理答案,使用轮询ID作为还原其他参数的键

$params = [
    'chat_id'      => $pollRow['chat'],
    'message_id'   => $pollRow['message']
];
$URL = $TgAPI.'bot'.$bot['token'].'/stopPoll';
$ch = curl_init($URL);
curl_setopt_array($ch, array(
    CURLOPT_HEADER => 0,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => $params,
    CURLOPT_TIMEOUT    => 60
));
$output = curl_exec($ch);

It`s needed to store poll id, message id, chat id from sendPoll return data.
Then in webhook call stopPoll and process an answer, using poll id as a key to restore other parameters(a db table with primary key pollId)

$params = [
    'chat_id'      => $pollRow['chat'],
    'message_id'   => $pollRow['message']
];
$URL = $TgAPI.'bot'.$bot['token'].'/stopPoll';
$ch = curl_init($URL);
curl_setopt_array($ch, array(
    CURLOPT_HEADER => 0,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => $params,
    CURLOPT_TIMEOUT    => 60
));
$output = curl_exec($ch);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文