|
2 | 2 | $msgInfo = json_decode(file_get_contents("messagewizwiz.json"),true);
|
3 | 3 | $offset = $msgInfo['offset']??-1;
|
4 | 4 | $messageParam = json_decode($msgInfo['text']);
|
5 |
| - |
6 |
| -if($offset == '-1') exit; |
| 5 | +$rateLimit = $msgInfo['rateLimit']??0; |
7 | 6 |
|
8 | 7 | include_once '../baseInfo.php';
|
9 | 8 | include_once '../config.php';
|
10 | 9 | include_once 'jdf.php';
|
| 10 | + |
| 11 | +if(time() > $rateLimit){ |
| 12 | + $rate = json_decode(file_get_contents("https://api.changeto.technology/api/rate"),true)['result']; |
| 13 | + if(!empty($rate['USD'])) $botState['USDRate'] = $rate['USD']; |
| 14 | + if(!empty($rate['TRX'])) $botState['TRXRate'] = $rate['TRX']; |
| 15 | + |
| 16 | + $stmt = $connection->prepare("SELECT * FROM `setting` WHERE `type` = 'BOT_STATES'"); |
| 17 | + $stmt->execute(); |
| 18 | + $isExists = $stmt->get_result(); |
| 19 | + $stmt->close(); |
| 20 | + if($isExists->num_rows>0) $query = "UPDATE `setting` SET `value` = ? WHERE `type` = 'BOT_STATES'"; |
| 21 | + else $query = "INSERT INTO `setting` (`type`, `value`) VALUES ('BOT_STATES', ?)"; |
| 22 | + $newData = json_encode($botState); |
| 23 | + |
| 24 | + $stmt = $connection->prepare($query); |
| 25 | + $stmt->bind_param("s", $newData); |
| 26 | + $stmt->execute(); |
| 27 | + $stmt->close(); |
| 28 | + |
| 29 | + $msgInfo['rateLimit'] = strtotime("+1 hour"); |
| 30 | + file_put_contents("messagewizwiz.json",json_encode($msgInfo)); |
| 31 | + |
| 32 | +} |
| 33 | + |
| 34 | + |
| 35 | +if($offset == '-1') exit; |
| 36 | + |
11 | 37 | if($offset == '0'){
|
12 | 38 | if($messageParam->type == "forwardall") $msg = "عملیات هدایت همگانی شروع شد";
|
13 | 39 | else $msg = "عملیات ارسال پیام همگانی شروع شد";
|
|
0 commit comments