forked from wizwizdev/wizwizxui-timebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messagewizwiz.php
78 lines (74 loc) · 2.9 KB
/
messagewizwiz.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
$msgInfo = json_decode(file_get_contents("messagewizwiz.json"),true);
$offset = $msgInfo['offset'];
$messageParam = json_decode($msgInfo['text']);
if($offset == '-1') exit;
include_once 'baseInfo.php';
include_once 'config.php';
include_once 'jdf.php';
if($offset == '0'){
bot('sendMessage',[
'chat_id'=>$admin,
'text'=>"عملیات ارسال پیام همگانی شروع شد"
]);
}
$stmt = $connection->prepare("SELECT * FROM `users`ORDER BY `id` LIMIT 250 OFFSET ?");
$stmt->bind_param("i", $offset);
$stmt->execute();
$usersList = $stmt->get_result();
$stmt->close();
if( $usersList->num_rows > 1 ) {
while($user = $usersList->fetch_assoc()){
if($messageParam->type == 'text'){
sendMessage($messageParam->value,null,null,$user['userid']);
}else {
if($messageParam->type == 'music'){
bot('sendAudio',[
'chat_id' => $user['userid'],
'audio' => $messageParam->value->fileid,
'caption' => $messageParam->value->caption,
]);
}elseif($messageParam->type == 'video'){
bot('sendVideo',[
'chat_id' => $user['userid'],
'video' => $messageParam->value->fileid,
'caption' => $messageParam->value->caption,
]);
}elseif($messageParam->type == 'voice'){
bot('sendVoice',[
'chat_id' => $user['userid'],
'voice' => $messageParam->value->fileid,
'caption' => $messageParam->value->caption,
]);
}elseif($messageParam->type == 'document'){
bot('sendDocument',[
'chat_id' => $user['userid'],
'document' => $messageParam->value->fileid,
'caption' => $messageParam->value->caption,
]);
}elseif($messageParam->type == 'photo'){
bot('sendPhoto', [
'chat_id' => $user['userid'],
'photo' => $messageParam->value->fileid,
'caption' => $messageParam->value->caption,
]);
}else {
bot('sendDocument',[
'chat_id' => $user['userid'],
'document' => $messageParam->value->fileid,
'caption' => $messageParam->value->caption,
]);
}
}
$offset++;
}
$msgInfo['offset'] = $offset;
file_put_contents("messagewizwiz.json",json_encode($msgInfo));
}else{
bot('sendMessage',[
'chat_id'=>$admin,
'text'=>"عملیات ارسال پیام همگانی با موفقیت انجام شد\nبه " . $offset . " نفر پیامتو فرستادم"
]);
$msgInfo['offset'] = -1;
file_put_contents("messagewizwiz.json",json_encode($msgInfo));
}