-
Notifications
You must be signed in to change notification settings - Fork 4
/
base_piag.php
44 lines (37 loc) · 1.13 KB
/
base_piag.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
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
require 'madeline.php';
class EventHandler extends \danog\MadelineProto\EventHandler
{
public function onUpdateNewChannelMessage(array $update): Generator
{
yield $this->onUpdateNewMessage($update);
}
public function onUpdateNewMessage(array $update): Generator
{
if ($update['message']['_'] === 'messageEmpty') {
return;
}
[
$msg_id,
$text,
$from_id,
$reply_id
] = [
$update['message']['id'] ?? false,
$update['message']['message'] ?? '',
$update['message']['from_id'] ?? false,
$update['message']['reply_to_msg_id'] ?? false
];
// Codes ...
}
}
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->async(true);
$MadelineProto->loop(function () use ($MadelineProto) {
yield $MadelineProto->start();
yield $MadelineProto->setEventHandler(EventHandler::class);
});
$MadelineProto->loop();