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