Skip to content

Commit 7b00065

Browse files
authored
Update bot.php
1 parent c474946 commit 7b00065

File tree

1 file changed

+136
-22
lines changed

1 file changed

+136
-22
lines changed

bot.php

Lines changed: 136 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
sendMessage($mainValues['banned']);
77
exit();
88
}
9+
$checkSpam = checkSpam();
10+
if(is_numeric($checkSpam)){
11+
$time = jdate("Y-m-d H:i:s", $checkSpam);
12+
sendMessage("اکانت شما به دلیل اسپم مسدود شده است\nزمان آزادسازی اکانت شما: \n$time");
13+
exit();
14+
}
15+
916
if(preg_match("/^haveJoined(.*)/",$data,$match)){
1017
if ($joniedState== "kicked" || $joniedState== "left"){
1118
alert($mainValues['not_joine_yet']);
@@ -64,7 +71,9 @@
6471
$text = "/start";
6572
}
6673
if($data == "agentsList" && ($from_id == $admin || $userInfo['isAdmin'] == true)){
67-
editText($message_id,$mainValues['agents_list'], getAgentsList());
74+
$keys = getAgentsList();
75+
if($keys != null) editText($message_id,$mainValues['agents_list'], $keys);
76+
else alert("نماینده ای یافت نشد");
6877
}
6978
if(preg_match('/^agentDetails(\d+)/',$data,$match) && ($from_id == $admin || $userInfo['isAdmin'] == true)){
7079
$userDetail = bot('getChat',['chat_id'=>$match[1]])->result;
@@ -80,7 +89,9 @@
8089
$stmt->close();
8190

8291
alert($mainValues['agent_deleted_successfuly']);
83-
editKeys(getAgentsList());
92+
$keys = getAgentsList();
93+
if($keys != null) editKeys($keys);
94+
else editKeys(json_encode(['inline_keyboard'=>[[['text'=>$buttonValues['back_button'],'callback_data'=>"managePanel"]]]]));
8495
}
8596
if(preg_match('/^editAgentDiscount(\d+)/',$data,$match) && ($from_id == $admin || $userInfo['isAdmin'] == true)){
8697
delMessage();
@@ -226,6 +237,25 @@
226237
}
227238
editText($message_id,$mainValues['change_bot_settings_message'],getBotSettingKeys());
228239
}
240+
if($data=="changeUpdateConfigLinkState" && ($from_id == $admin || $userInfo['isAdmin'] == true)){
241+
$newValue = $botState['updateConnectionState']=="robot"?"site":"robot";
242+
$botState['updateConnectionState']= $newValue;
243+
244+
$stmt = $connection->prepare("SELECT * FROM `setting` WHERE `type` = 'BOT_STATES'");
245+
$stmt->execute();
246+
$isExists = $stmt->get_result();
247+
$stmt->close();
248+
if($isExists->num_rows>0) $query = "UPDATE `setting` SET `value` = ? WHERE `type` = 'BOT_STATES'";
249+
else $query = "INSERT INTO `setting` (`type`, `value`) VALUES ('BOT_STATES', ?)";
250+
$newData = json_encode($botState);
251+
252+
$stmt = $connection->prepare($query);
253+
$stmt->bind_param("s", $newData);
254+
$stmt->execute();
255+
$stmt->close();
256+
257+
editText($message_id,$mainValues['change_bot_settings_message'],getBotSettingKeys());
258+
}
229259
if(($data=="gateWays_Channels" or preg_match("/^changeGateWays(\w+)/",$data,$match)) && ($from_id == $admin || $userInfo['isAdmin'] == true)){
230260
if($data!="gateWays_Channels"){
231261
$newValue = $botState[$match[1]]=="on"?"off":"on";
@@ -499,6 +529,7 @@
499529
$stmt->execute();
500530
$inviteText = $stmt->get_result()->fetch_assoc()['value'];
501531
if($inviteText != null){
532+
delMessage();
502533
$inviteText = json_decode($inviteText,true);
503534

504535
$stmt = $connection->prepare("SELECT * FROM `setting` WHERE `type` = 'INVITE_BANNER_AMOUNT'");
@@ -519,7 +550,7 @@
519550
$res = sendPhoto($inviteText['file_id'],$txt,null,"HTML");
520551
}
521552
$msgId = $res->result->message_id;
522-
sendMessage("با لینک بالا دوستاتو به ربات دعوت کن و با هر خرید $inviteAmount بدست بیار",null,null,null,$msgId);
553+
sendMessage("با لینک بالا دوستاتو به ربات دعوت کن و با هر خرید $inviteAmount بدست بیار",json_encode(['inline_keyboard'=>[[['text'=>$buttonValues['back_to_main'],'callback_data'=>"mainMenu"]]]]),null,null,$msgId);
523554
}
524555
else alert("این قسمت غیر فعال است");
525556
}
@@ -1501,7 +1532,7 @@
15011532
]]);
15021533

15031534
$msg = str_replace(['TYPE', 'USER-ID', 'USERNAME', 'NAME', 'PRICE', 'REMARK', 'VOLUME', 'DAYS'],
1504-
['ارزی ریالی', $from_id, $username, $first_name, $price, $remark,$volume, $days], $mainValues['buy_custom_account_request']);
1535+
['ارزی ریالی', $from_id, $username, $first_name, $price, $remark,$volume, $days], $mainValues['buy_new_account_request']);
15051536

15061537
sendMessage($msg,$keys,"html", $admin);
15071538
}
@@ -1539,7 +1570,7 @@
15391570
exit;
15401571
}
15411572
$stmt = $connection->prepare("UPDATE `orders_list` SET `expire_date` = ?, `notif` = 0 WHERE `id` = ?");
1542-
$newExpire = $expire_date + $days * 86400;
1573+
$newExpire = $time + $days * 86400;
15431574
$stmt->bind_param("ii", $newExpire, $oid);
15441575
$stmt->execute();
15451576
$stmt->close();
@@ -1815,6 +1846,45 @@
18151846

18161847
editText($message_id,'⏳ کم کم برا همه ارسال میشه ... ',getMainKeys());
18171848
}
1849+
if($data=="forwardToAll" && ($from_id == $admin || $userInfo['isAdmin'] == true)){
1850+
$sendInfo = json_decode(file_get_contents("settings/messagewizwiz.json"),true);
1851+
$offset = $sendInfo['offset'];
1852+
1853+
if($offset != -1) {
1854+
$stmt = $connection->prepare("SELECT * FROM `users`");
1855+
$stmt->execute();
1856+
$usersCount = $stmt->get_result()->num_rows;
1857+
$stmt->close();
1858+
1859+
$leftMessages = $offset == 0 ? $usersCount - $offset : $usersCount - $offset;
1860+
$offset = $offset == 0 ? $offset : $offset;
1861+
sendMessage("
1862+
❗️ یک فروارد همگانی در صف انتشار می باشد لطفا صبور باشید ...
1863+
1864+
🔰 تعداد کاربران : $usersCount
1865+
☑️ فروارد شده : $offset
1866+
📣 باقیمانده : $leftMessages
1867+
   
1868+
");exit;
1869+
}
1870+
1871+
delMessage();
1872+
sendMessage($mainValues['forward_your_message'], $cancelKey);
1873+
setUser($data);
1874+
}
1875+
if($userInfo['step'] == "forwardToAll" && ($from_id == $admin || $userInfo['isAdmin'] == true) && $text != $buttonValues['cancel']){
1876+
$messageValue = json_encode(['type'=>'forwardall','message_id'=> $message_id, 'chat_id'=>$chat_id]);
1877+
1878+
$sendInfo = json_decode(file_get_contents("settings/messagewizwiz.json"),true);
1879+
$sendInfo['text'] = $messageValue;
1880+
file_put_contents("settings/messagewizwiz.json",json_encode($sendInfo));
1881+
1882+
setUser();
1883+
sendMessage('⏳ مرسی از پیامت ... ',$removeKeyboard);
1884+
sendMessage("برای همه فروارد کنم؟",json_encode(['inline_keyboard'=>[
1885+
[['text'=>"بفرست",'callback_data'=>"yesSend2All"],['text'=>"نه نفرست",'callback_data'=>"noDontSend2all"]]
1886+
]]));
1887+
}
18181888
if(preg_match('/selectServer(\d+)/',$data, $match) && ($botState['sellState']=="on" || ($from_id == $admin || $userInfo['isAdmin'] == true)) ) {
18191889
$sid = $match[1];
18201890

@@ -1911,10 +1981,14 @@
19111981
sendMessage("😡|لطفا فقط عدد ارسال کن");
19121982
exit();
19131983
}
1914-
elseif($text <=0){
1984+
elseif($text <1){
19151985
sendMessage("لطفا عددی بزرگتر از 0 وارد کن");
19161986
exit();
19171987
}
1988+
elseif(strpos($text,".")!==FALSE){
1989+
sendMessage(" عدد اعشاری مجاز نیست");
1990+
exit();
1991+
}
19181992
$id = $match[1];
19191993
$price = $botState['dayPrice'];
19201994
if($userInfo['temp'] == "agentBuy" && $userInfo['is_agent'] == true) $price -= ($price * $userInfo['discount_percent'] / 100);
@@ -1927,11 +2001,14 @@
19272001
sendMessage("😡|لطفا فقط عدد ارسال کن");
19282002
exit();
19292003
}
1930-
elseif($text <=0){
2004+
elseif($text <1){
19312005
sendMessage("لطفا عددی بزرگتر از 0 وارد کن");
19322006
exit();
19332007
}
1934-
2008+
elseif(strpos($text,".")!==FALSE){
2009+
sendMessage("عدد اعشاری مجاز نیست");
2010+
exit();
2011+
}
19352012
sendMessage($mainValues['customer_custome_plan_name']);
19362013
setUser("enterCustomPlanName" . $match[1] . "_" . $match[2] . "_" . $match[3] . "_" . $text);
19372014
}
@@ -2216,7 +2293,7 @@
22162293
}else{
22172294
if($userInfo['temp'] == "agentMuchBuy"){
22182295
setUser($data);
2219-
sendMessage($mainValues['enter_account_amount']);
2296+
sendMessage($mainValues['enter_account_amount'], $cancelKey);
22202297
exit();
22212298
}
22222299
}
@@ -3100,7 +3177,7 @@
31003177
if($payInfo['type'] == "RENEW_SCONFIG"){$msg = str_replace(['TYPE', 'USER-ID', 'USERNAME', 'NAME', 'PRICE', 'REMARK', 'VOLUME', 'DAYS'],
31013178
['کیف پول', $from_id, $username, $first_name, $price, $remark,$volume, $days], $mainValues['renew_account_request_message']);}
31023179
else{$msg = str_replace(['TYPE', 'USER-ID', 'USERNAME', 'NAME', 'PRICE', 'REMARK', 'VOLUME', 'DAYS'],
3103-
['کیف پول', $from_id, $username, $first_name, $price, $remark,$volume, $days], $mainValues['buy_custom_account_request']);}
3180+
['کیف پول', $from_id, $username, $first_name, $price, $remark,$volume, $days], $mainValues['buy_new_account_request']);}
31043181

31053182
sendMessage($msg,$keys,"html", $admin);
31063183
}
@@ -4708,7 +4785,7 @@
47084785
if(preg_match('/freeTrial(\d+)/',$data,$match)) {
47094786
$id = $match[1];
47104787

4711-
if($userInfo['freetrial'] == 'used' and !($from_id == $admin)){
4788+
if($userInfo['freetrial'] == 'used' and !($from_id == $admin) && $userInfo['discount_percent'] != "100"){
47124789
alert('⚠️شما قبلا هدیه رایگان خود را دریافت کردید');
47134790
exit;
47144791
}
@@ -4737,6 +4814,12 @@
47374814
$customPort = $file_detail['custom_port'];
47384815
$customSni = $file_detail['custom_sni'];
47394816

4817+
$agentBought = false;
4818+
if($userInfo['temp'] == "agentBuy" || $userInfo['temp'] == "agentMuchBuy"){
4819+
$agentBought = true;
4820+
$price -= ($price * $userInfo['discount_percent'] / 100);
4821+
}
4822+
47404823
if($acount == 0 and $inbound_id != 0){
47414824
alert($mainValues['out_of_connection_capacity']);
47424825
exit;
@@ -4852,10 +4935,10 @@
48524935

48534936
$vray_link = json_encode($vraylink);
48544937
$stmt = $connection->prepare("INSERT INTO `orders_list`
4855-
(`userid`, `token`, `transid`, `fileid`, `server_id`, `inbound_id`, `remark`, `protocol`, `expire_date`, `link`, `amount`, `status`, `date`, `notif`, `rahgozar`)
4856-
VALUES (?, ?, '', ?, ?, ?, ?, ?, ?, ?, ?,1, ?, 0, ?);");
4938+
(`userid`, `token`, `transid`, `fileid`, `server_id`, `inbound_id`, `remark`, `protocol`, `expire_date`, `link`, `amount`, `status`, `date`, `notif`, `rahgozar`, `agent_bought`)
4939+
VALUES (?, ?, '', ?, ?, ?, ?, ?, ?, ?, ?,1, ?, 0, ?, ?);");
48574940

4858-
$stmt->bind_param("isiiissisiii", $from_id, $token, $id, $server_id, $inbound_id, $remark, $protocol, $expire_date, $vray_link, $price, $date, $rahgozar);
4941+
$stmt->bind_param("isiiissisiiii", $from_id, $token, $id, $server_id, $inbound_id, $remark, $protocol, $expire_date, $vray_link, $price, $date, $rahgozar, $agentBought);
48594942
$stmt->execute();
48604943
$order = $stmt->get_result();
48614944
$stmt->close();
@@ -5515,8 +5598,25 @@
55155598
exit();
55165599
}
55175600

5518-
$stmt = $connection->prepare("UPDATE `server_plans` SET `inbound_id`=?,`step`=64 WHERE `active`=0");
5519-
$stmt->bind_param("i", $text);
5601+
$stmt = $connection->prepare("SELECT * FROM `server_plans` WHERE `active` = 0");
5602+
$stmt->execute();
5603+
$res = $stmt->get_result()->fetch_assoc();
5604+
$stmt->close();
5605+
5606+
5607+
$response = getJson($res['server_id'])->obj;
5608+
foreach($response as $row){
5609+
if($row->id == $text) {
5610+
$netType = json_decode($row->streamSettings)->network;
5611+
}
5612+
}
5613+
if(is_null($netType)){
5614+
sendMessage("کانفیگی با این سطر آیدی یافت نشد");
5615+
exit();
5616+
}
5617+
5618+
$stmt = $connection->prepare("UPDATE `server_plans` SET `type` = ?, `inbound_id`=?,`step`=64 WHERE `active`=0");
5619+
$stmt->bind_param("si", $netType, $text);
55205620
$stmt->execute();
55215621
$stmt->close();
55225622

@@ -6242,6 +6342,8 @@
62426342
if($inboundId == 0){
62436343
foreach($response as $row){
62446344
if($row->remark == $remark) {
6345+
$inboundRemark = $row->remark;
6346+
$iId = $row->id;
62456347
$port = $row->port;
62466348
$protocol = $row->protocol;
62476349
$netType = json_decode($row->streamSettings)->network;
@@ -6254,6 +6356,8 @@
62546356
}else{
62556357
foreach($response as $row){
62566358
if($row->id == $inboundId) {
6359+
$iId = $row->id;
6360+
$inboundRemark = $row->remark;
62576361
$port = $row->port;
62586362
$protocol = $row->protocol;
62596363
$netType = json_decode($row->streamSettings)->network;
@@ -6270,7 +6374,19 @@
62706374
}
62716375
}
62726376

6273-
6377+
if($botState['updateConnectionState'] == "robot"){
6378+
$stmt = $connection->prepare("SELECT * FROM `server_config` WHERE `id`=?");
6379+
$stmt->bind_param("i", $file_id);
6380+
$stmt->execute();
6381+
$server_config = $stmt->get_result()->fetch_assoc();
6382+
6383+
$netType = $file_detail['type'];
6384+
$protocol = $file_detail['protocol'];
6385+
$security = $server_config['security'];
6386+
6387+
// editInbound($server_id, $uuid, $inboundRemark, $protocol, $netType, $security, $rahgozar);
6388+
updateConfig($server_id, $iId, $protocol, $netType, $security, $rahgozar);
6389+
}
62746390
$vraylink = getConnectionLink($server_id, $uuid, $protocol, $remark, $port, $netType, $inboundId, $rahgozar, $customPath, $customPort, $customSni);
62756391

62766392
$vray_link = json_encode($vraylink);
@@ -6346,6 +6462,7 @@
63466462
$keys = getOrderDetailKeys($from_id, $oid);
63476463
editText($message_id, $keys['msg'], $keys['keyboard'],"HTML");
63486464
}
6465+
63496466
if(preg_match('/changeAccProtocol(\d+)_(\d+)_(.*)/', $data,$match)){
63506467
$fid = $match[1];
63516468
$oid = $match[2];
@@ -6680,7 +6797,7 @@
66806797
exit;
66816798
}
66826799
$stmt = $connection->prepare("UPDATE `orders_list` SET `expire_date` = ?, `notif` = 0 WHERE `id` = ?");
6683-
$newExpire = $expire_date + $days * 86400;
6800+
$newExpire = $time + $days * 86400;
66846801
$stmt->bind_param("ii", $newExpire, $oid);
66856802
$stmt->execute();
66866803
$stmt->close();
@@ -6782,7 +6899,7 @@
67826899
exit;
67836900
}
67846901
$stmt = $connection->prepare("UPDATE `orders_list` SET `expire_date` = ?, `notif` = 0 WHERE `id` = ?");
6785-
$newExpire = $expire_date + $days * 86400;
6902+
$newExpire = $time + $days * 86400;
67866903
$stmt->bind_param("ii", $newExpire, $oid);
67876904
$stmt->execute();
67886905
$stmt->close();
@@ -8169,7 +8286,6 @@
81698286
if(preg_match('/^addServerPanePassword(.*)/',$userInfo['step'],$match) and $text != $buttonValues['cancel']){
81708287
sendMessage("⏳ در حال ورود به اکانت ...");
81718288
$data = json_decode($match[1],true);
8172-
81738289
$title = $data['title'];
81748290
$ucount = $data['ucount'];
81758291
$remark = $data['remark'];
@@ -8190,7 +8306,6 @@
81908306
"username" => $serverName,
81918307
"password" => $serverPass
81928308
);
8193-
81948309
$ch = curl_init();
81958310
curl_setopt($ch, CURLOPT_URL, $loginUrl);
81968311
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
@@ -8224,7 +8339,6 @@
82248339
$rowId = $stmt->insert_id;
82258340
$stmt->close();
82268341

8227-
82288342
$stmt = $connection->prepare("INSERT INTO `server_config` (`id`, `panel_url`, `ip`, `sni`, `header_type`, `request_header`, `response_header`, `security`, `tlsSettings`, `username`, `password`)
82298343
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
82308344
$stmt->bind_param("issssssssss", $rowId, $panel_url, $ip, $sni, $header_type, $request_header, $response_header, $security, $tlsSettings, $serverName, $serverPass);

0 commit comments

Comments
 (0)