-
Notifications
You must be signed in to change notification settings - Fork 63
/
bot.php
41 lines (37 loc) · 2.1 KB
/
bot.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
<?php
$bot = function ($update) use (&$MadelineProto, &$schedule, &$me, &$include, &$sm) {
foreach ($update as $varname => $var) { if ($varname !== 'update') $$varname = $var; } //NON TOCCARE - dichiara variabili $chatID $userID ecc.
//COMANDI BOT
if (isset($update['update']['message']['out']) and $update['update']['message']['out'] == true) return; //ignora messaggi dall'userbot stesso
if ($msg === '/info') {
yield $sm($chatID, "<b>Info chat:</b>\nID: $chatID\nTitolo: $title\nUsername chat: @$chatusername\nTipo: $type\n\n<b>Informazioni utente:</b>\nID: $userID\nNome: $name\nUsername: @$username", $msgid);
}
if ($msg === '/async') {
yield $sm($chatID, '<b>1OO%</b> Async');
yield $MadelineProto->sleep(5);
yield $sm($chatID, 'Second message');
}
if ($msg === '/schedule') {
yield $sm($chatID, 'Message scheduled.');
yield $schedule(time() + 10, function () use (&$MadelineProto, &$sm, $chatID) {
yield $sm($chatID, 'Scheduled message 🤩🤩🤩'); //this message will be sent after 10 seconds
});
}
if ($msg === '/schedule2') {
yield $sm($chatID, 'Message scheduled at OO:OO.');
yield $schedule('tomorrow 00:00', function () use (&$MadelineProto, &$sm, $chatID) {
yield $sm($chatID, 'Buon '. date('l')); //this message will be sent after 10 seconds
});
}
if ($type === 'user' and $msg === '/drole') {
yield $MadelineProto->messages->sendScreenshotNotification(['peer' => $chatID, 'reply_to_msg_id' => $msgid]);
}
if ($msg === '/help') {
yield $sm($chatID, "Techs:\n\n/info\n/async\n/schedule\n/schedule2\n/drole (pvt)\n/help", $msgid);
}
};
//FUNZIONI
$sm = function ($chatID, $text, $reply = NULL, $parsemode = 'HTML') use (&$MadelineProto) {
if (isset($reply)) return yield $MadelineProto->messages->sendMessage(['peer' => $chatID, 'message' => $text, 'reply_to_msg_id' => $reply, 'parse_mode' => $parsemode]);
else return yield $MadelineProto->messages->sendMessage(['peer' => $chatID, 'message' => $text, 'parse_mode' => $parsemode]);
};