erjanmx /
php-nambaone-bot
| 1 | <?php |
||
| 2 | require __DIR__ . '/../vendor/autoload.php'; |
||
| 3 | |||
| 4 | use erjanmx\nambaone\Client; |
||
| 5 | use erjanmx\nambaone\ClientException; |
||
| 6 | |||
| 7 | $API_KEY = ''; |
||
| 8 | try { |
||
| 9 | $client = new Client($API_KEY); |
||
| 10 | |||
| 11 | $client->command('user/follow', function ($user) use ($client) { |
||
| 12 | $chat = $client->api->createChat($user['id']); |
||
| 13 | |||
| 14 | $client->to($chat->data->id)->send('Welcome'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 15 | }); |
||
| 16 | |||
| 17 | $client->command('message/new', function ($message) use ($client) { |
||
| 18 | $client->to($message['chat_id'])->setType($message['type'])->send($message['content']); |
||
| 19 | }); |
||
| 20 | |||
| 21 | $client->handleEvents(); |
||
| 22 | } catch (ClientException $e) { |
||
| 23 | //handle exception |
||
| 24 | } |
||
| 25 |