|
2 | 2 | include_once '../baseInfo.php'; |
3 | 3 | include_once '../config.php'; |
4 | 4 |
|
5 | | -if(file_exists("botstate.json")){ |
6 | | - $botState = json_decode(file_get_contents("botstate.json"),true); |
7 | | - $sellState=$botState['sellState']=="off"?"خاموش ❌":"روشن ✅"; |
8 | | - $searchState=$botState['searchState']=="off"?"خاموش ❌":"روشن ✅"; |
9 | | - $rewaredTime = ($botState['rewaredTime']??0); |
10 | | - $rewaredChannel = $botState['rewardChannel']; |
11 | 5 |
|
12 | | - if($rewaredTime>0 && $rewaredChannel != null){ |
13 | | - $lastTime = $botState['lastRewardMessage']??0; |
14 | | - if(time() > $lastTime){ |
15 | | - $time = time() - ($rewaredTime * 60 * 60); |
16 | | - $stmt = $connection->prepare("SELECT SUM(amount) as total FROM `orders_list` WHERE `date` > ?"); |
17 | | - $stmt->bind_param("i", $time); |
18 | | - $stmt->execute(); |
19 | | - $totalRewards = number_format($stmt->get_result()->fetch_assoc()['total']) . " تومان"; |
20 | | - $stmt->close(); |
21 | | - $botState['lastRewardMessage']=time() + ($rewaredTime * 60 * 60); |
22 | | - file_put_contents("botstate.json",json_encode($botState)); |
23 | | - $txt = " |
| 6 | +$sellState=$botState['sellState']=="off"?"خاموش ❌":"روشن ✅"; |
| 7 | +$searchState=$botState['searchState']=="off"?"خاموش ❌":"روشن ✅"; |
| 8 | +$rewaredTime = ($botState['rewaredTime']??0); |
| 9 | +$rewaredChannel = $botState['rewardChannel']; |
| 10 | + |
| 11 | +if($rewaredTime>0 && $rewaredChannel != null){ |
| 12 | + $lastTime = $botState['lastRewardMessage']??0; |
| 13 | + if(time() > $lastTime){ |
| 14 | + $time = time() - ($rewaredTime * 60 * 60); |
| 15 | + $stmt = $connection->prepare("SELECT SUM(amount) as total FROM `orders_list` WHERE `date` > ?"); |
| 16 | + $stmt->bind_param("i", $time); |
| 17 | + $stmt->execute(); |
| 18 | + $totalRewards = number_format($stmt->get_result()->fetch_assoc()['total']) . " تومان"; |
| 19 | + $stmt->close(); |
| 20 | + |
| 21 | + $botState['lastRewardMessage']=time() + ($rewaredTime * 60 * 60); |
| 22 | + |
| 23 | + $stmt = $connection->prepare("SELECT * FROM `setting` WHERE `type` = 'BOT_STATES'"); |
| 24 | + $stmt->execute(); |
| 25 | + $isExists = $stmt->get_result(); |
| 26 | + $stmt->close(); |
| 27 | + if($isExists->num_rows>0) $query = "UPDATE `setting` SET `value` = ? WHERE `type` = 'BOT_STATES'"; |
| 28 | + else $query = "INSERT INTO `setting` (`type`, `value`) VALUES ('BOT_STATES', ?)"; |
| 29 | + $newData = json_encode($botState); |
| 30 | + |
| 31 | + $stmt = $connection->prepare($query); |
| 32 | + $stmt->bind_param("s", $newData); |
| 33 | + $stmt->execute(); |
| 34 | + $stmt->close(); |
| 35 | + |
| 36 | + $txt = " |
24 | 37 | 🔰درآمد من در $rewaredTime ساعت گذشته |
25 | 38 |
|
26 | 39 | 💰مبلغ : $totalRewards تومان |
27 | 40 |
|
28 | 41 | ☑️ $channelLock |
29 | 42 |
|
30 | 43 | "; |
31 | | - sendMessage($txt, null, null, $rewaredChannel); |
32 | | - } |
33 | | - } |
34 | | -} |
| 44 | + sendMessage($txt, null, null, $rewaredChannel); |
| 45 | + } |
| 46 | +} |
0 commit comments