Skip to content

Commit 9b51152

Browse files
authored
Update messagewizwiz.php
1 parent dbb91ae commit 9b51152

File tree

1 file changed

+103
-111
lines changed

1 file changed

+103
-111
lines changed

settings/messagewizwiz.php

Lines changed: 103 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<?php
2-
$msgInfo = json_decode(file_get_contents("messagewizwiz.json"),true);
3-
$offset = $msgInfo['offset']??-1;
4-
$messageParam = json_decode($msgInfo['text']);
5-
$rateLimit = $msgInfo['rateLimit']??0;
6-
72
include_once '../baseInfo.php';
83
include_once '../config.php';
94
include_once 'jdf.php';
105

6+
$rateLimit = $botState['rateLimit']??0;
117
if(time() > $rateLimit){
128
$rate = json_decode(file_get_contents("https://api.changeto.technology/api/rate"),true)['result'];
139
if(!empty($rate['USD'])) $botState['USDRate'] = $rate['USD'];
1410
if(!empty($rate['TRX'])) $botState['TRXRate'] = $rate['TRX'];
11+
$botState['rateLimit'] = strtotime("+1 hour");
1512

1613
$stmt = $connection->prepare("SELECT * FROM `setting` WHERE `type` = 'BOT_STATES'");
1714
$stmt->execute();
@@ -25,121 +22,116 @@
2522
$stmt->bind_param("s", $newData);
2623
$stmt->execute();
2724
$stmt->close();
28-
29-
$msgInfo['rateLimit'] = strtotime("+1 hour");
30-
file_put_contents("messagewizwiz.json",json_encode($msgInfo));
31-
3225
}
3326

34-
35-
if($offset == '-1') exit;
36-
37-
if($offset == '0'){
38-
if($messageParam->type == "forwardall") $msg = "عملیات هدایت همگانی شروع شد";
39-
else $msg = "عملیات ارسال پیام همگانی شروع شد";
40-
41-
bot('sendMessage',[
42-
'chat_id'=>$admin,
43-
'text'=>$msg
44-
]);
45-
}
46-
$stmt = $connection->prepare("SELECT * FROM `users`ORDER BY `id` LIMIT 50 OFFSET ?");
47-
$stmt->bind_param("i", $offset);
27+
$stmt = $connection->prepare("SELECT * FROM `send_list` WHERE `state` = 1 LIMIT 1");
4828
$stmt->execute();
49-
$usersList = $stmt->get_result();
29+
$list = $stmt->get_result();
5030
$stmt->close();
5131

52-
if( $usersList->num_rows > 1 ) {
53-
while($user = $usersList->fetch_assoc()){
54-
if($messageParam->type == 'text'){
55-
sendMessage($messageParam->value,json_encode([
56-
'inline_keyboard' => [
57-
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
58-
]
59-
]),null,$user['userid']);
60-
}elseif($messageParam->type == 'music'){
61-
bot('sendAudio',[
62-
'chat_id' => $user['userid'],
63-
'audio' => $messageParam->value->fileid,
64-
'caption' => $messageParam->value->caption,
65-
'reply_markup'=>json_encode([
66-
'inline_keyboard' => [
67-
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
68-
]
69-
])
70-
]);
71-
}elseif($messageParam->type == 'video'){
72-
bot('sendVideo',[
73-
'chat_id' => $user['userid'],
74-
'video' => $messageParam->value->fileid,
75-
'caption' => $messageParam->value->caption,
76-
'reply_markup'=>json_encode([
77-
'inline_keyboard' => [
78-
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
79-
]
80-
])
81-
]);
82-
}elseif($messageParam->type == 'voice'){
83-
bot('sendVoice',[
84-
'chat_id' => $user['userid'],
85-
'voice' => $messageParam->value->fileid,
86-
'caption' => $messageParam->value->caption,
87-
'reply_markup'=>json_encode([
88-
'inline_keyboard' => [
89-
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
90-
]
91-
])
32+
if($list->num_rows > 0){
33+
$info = $list->fetch_assoc();
34+
35+
$sendId = $info['id'];
36+
$offset = $info['offset'];
37+
$type = $info['type'];
38+
$file_id = $info['file_id'];
39+
$chat_id = $info['chat_id'];
40+
$text = $info['text'];
41+
$message_id = $info['message_id'];
42+
43+
if($offset == '0'){
44+
if($type == "forwardall") $msg = "عملیات هدایت همگانی شروع شد";
45+
else $msg = "عملیات ارسال پیام همگانی شروع شد";
46+
47+
bot('sendMessage',[
48+
'chat_id'=>$admin,
49+
'text'=>$msg
9250
]);
93-
}elseif($messageParam->type == 'document'){
94-
bot('sendDocument',[
95-
'chat_id' => $user['userid'],
96-
'document' => $messageParam->value->fileid,
97-
'caption' => $messageParam->value->caption,
98-
'reply_markup'=>json_encode([
99-
'inline_keyboard' => [
100-
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
101-
]
102-
])
51+
}
52+
53+
$stmt = $connection->prepare("SELECT * FROM `users`ORDER BY `id` LIMIT 50 OFFSET ?");
54+
$stmt->bind_param("i", $offset);
55+
$stmt->execute();
56+
$usersList = $stmt->get_result();
57+
$stmt->close();
58+
59+
$keys = json_encode([
60+
'inline_keyboard' => [
61+
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
62+
]
10363
]);
104-
}elseif($messageParam->type == 'photo'){
105-
bot('sendPhoto', [
106-
'chat_id' => $user['userid'],
107-
'photo' => $messageParam->value->fileid,
108-
'caption' => $messageParam->value->caption,
109-
'reply_markup'=>json_encode([
110-
'inline_keyboard' => [
111-
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
112-
]
113-
])
114-
]);
115-
}elseif($messageParam->type == "forwardall"){
116-
forwardmessage($user['userid'], $messageParam->chat_id, $messageParam->message_id);
64+
if($usersList->num_rows > 1) {
65+
while($user = $usersList->fetch_assoc()){
66+
if($type == 'text'){
67+
sendMessage($text,$keys,null,$user['userid']);
68+
}elseif($type == 'music'){
69+
bot('sendAudio',[
70+
'chat_id' => $user['userid'],
71+
'audio' => $file_id,
72+
'caption' => $text,
73+
'reply_markup'=>$keys
74+
]);
75+
}elseif($type == 'video'){
76+
bot('sendVideo',[
77+
'chat_id' => $user['userid'],
78+
'video' => $file_id,
79+
'caption' => $text,
80+
'reply_markup'=>$keys
81+
]);
82+
}elseif($type == 'voice'){
83+
bot('sendVoice',[
84+
'chat_id' => $user['userid'],
85+
'voice' => $file_id,
86+
'caption' => $text,
87+
'reply_markup'=>$keys
88+
]);
89+
}elseif($type == 'document'){
90+
bot('sendDocument',[
91+
'chat_id' => $user['userid'],
92+
'document' => $file_id,
93+
'caption' => $text,
94+
'reply_markup'=>$kes
95+
]);
96+
}elseif($type == 'photo'){
97+
bot('sendPhoto', [
98+
'chat_id' => $user['userid'],
99+
'photo' => $file_id,
100+
'caption' => $text,
101+
'reply_markup'=>$keys
102+
]);
103+
}elseif($type == "forwardall"){
104+
forwardmessage($user['userid'], $chat_id, $message_id);
105+
}
106+
else {
107+
bot('sendDocument',[
108+
'chat_id' => $user['userid'],
109+
'document' => $file_id,
110+
'caption' => $text,
111+
'reply_markup'=>$keys
112+
]);
113+
}
114+
$offset++;
117115
}
118-
else {
119-
bot('sendDocument',[
120-
'chat_id' => $user['userid'],
121-
'document' => $messageParam->value->fileid,
122-
'caption' => $messageParam->value->caption,
123-
'reply_markup'=>json_encode([
124-
'inline_keyboard' => [
125-
[['text'=>$buttonValues['start_bot'],'callback_data'=>"mainMenu"]]
126-
]
127-
])
116+
$stmt = $connection->prepare("UPDATE `send_list` SET `offset` = ? WHERE `id` = ?");
117+
$stmt->bind_param("ii", $offset, $sendId);
118+
$stmt->execute();
119+
$stmt->close();
120+
}else{
121+
if($type == "forwardall") $msg = "عملیات هدایت همگانی با موفقیت انجام شد";
122+
else $msg = "عملیات ارسال پیام همگانی با موفقیت انجام شد";
123+
124+
bot('sendMessage',[
125+
'chat_id'=>$admin,
126+
'text'=>$msg . "\nبه " . $offset . " نفر پیامتو فرستادم"
128127
]);
129-
}
130-
$offset++;
128+
129+
$stmt = $connection->prepare("DELETE FROM `send_list` WHERE `id` = ?");
130+
$stmt->bind_param('i', $sendId);
131+
$stmt->execute();
132+
$stmt->close();
131133
}
132-
$msgInfo['offset'] = $offset;
133-
file_put_contents("messagewizwiz.json",json_encode($msgInfo));
134-
}else{
135-
if($messageParam->type == "forwardall") $msg = "عملیات هدایت همگانی با موفقیت انجام شد";
136-
else $msg = "عملیات ارسال پیام همگانی با موفقیت انجام شد";
137-
138-
bot('sendMessage',[
139-
'chat_id'=>$admin,
140-
'text'=>$msg . "\nبه " . $offset . " نفر پیامتو فرستادم"
141-
]);
142-
$msgInfo['offset'] = -1;
143-
file_put_contents("messagewizwiz.json",json_encode($msgInfo));
144134
}
145135

136+
137+
?>

0 commit comments

Comments
 (0)