【发布时间】:2021-10-04 23:23:58
【问题描述】:
我开发了一个电报机器人,它的工作是在电报组中发布板球比赛的比分。只有在更新新分数时才需要发布分数。我正在尝试将旧分数存储在会话中,然后将其与新分数进行比较。
如果两个值(旧值和新值)不匹配,请将分数发布到组中,但由于某种未知原因,它不起作用
这是我的代码
<?php
session_start();
set_time_limit(0);
$token = 'xyz';
$group_name = 'xyz';
while(true){
$ipl = file_get_contents('https://cricket-api.vercel.app/cri.php?url=https://www.cricbuzz.com/live-cricket-scores/37632/dc-vs-csk-50th-match-indian-premier-league-2021');
$ipl_data = json_decode($ipl, true);
$current_score = $ipl_data['livescore']['current'];
if($current_score != $_SESSION['old_score']){
$bot = "https://api.telegram.org/bot{$token}/sendMessage?chat_id={$group_name}&text={$current_score}";
$hit = file_get_contents($bot);
}
$_SESSION['old_score'] = $current_score;
sleep(10);
}
?>
【问题讨论】:
-
您已经问过这个问题了:Send a message when the score gets an update - Telegram Bot 为了保持内容质量,明确禁止重复提问。请勿转载;改为编辑您的原始问题。
-
我没有转发同样的问题!这两个问题都有不同的问题。基本上是上一个问题的延续