1 | <?php |
||
2 | require __DIR__ . '/../vendor/autoload.php'; |
||
3 | |||
4 | use erjanmx\nambaone\Client; |
||
5 | use erjanmx\nambaone\EventsHandler; |
||
6 | use erjanmx\nambaone\ClientException; |
||
7 | |||
8 | /** |
||
9 | * @class |
||
10 | */ |
||
11 | class CustomEventsHandler extends EventsHandler |
||
12 | { |
||
13 | public $events = [ |
||
14 | 'message/new' => 'messageNew', |
||
15 | ]; |
||
16 | |||
17 | public function messageNew($data) |
||
18 | { |
||
19 | $this->client->to($data['chat_id'])->setType($data['type'])->setContent($data['content'])->send(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
20 | } |
||
21 | } |
||
22 | |||
23 | $API_KEY = ''; |
||
24 | try { |
||
25 | $client = new Client($API_KEY, new CustomEventsHandler()); |
||
26 | |||
27 | $client->handleEvents(); |
||
28 | } catch (ClientException $e) { |
||
29 | //handle exception |
||
30 | } |
||
31 |