Skip to content

Commit ff0d7b5

Browse files
authored
Update messagewizwiz.php
1 parent 9dd5803 commit ff0d7b5

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

settings/messagewizwiz.php

+28-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,38 @@
22
$msgInfo = json_decode(file_get_contents("messagewizwiz.json"),true);
33
$offset = $msgInfo['offset']??-1;
44
$messageParam = json_decode($msgInfo['text']);
5-
6-
if($offset == '-1') exit;
5+
$rateLimit = $msgInfo['rateLimit']??0;
76

87
include_once '../baseInfo.php';
98
include_once '../config.php';
109
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+
1137
if($offset == '0'){
1238
if($messageParam->type == "forwardall") $msg = "عملیات هدایت همگانی شروع شد";
1339
else $msg = "عملیات ارسال پیام همگانی شروع شد";

0 commit comments

Comments
 (0)