1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\TCommands;
- use Illuminate\Support\Facades\Log;
- use Telegram\Bot\Actions;
- use Telegram\Bot\Commands\Command;
- class TestCommand extends Command
- {
-
- protected $name = 'test';
-
- protected $aliases = ['listcommands'];
-
- protected $description = 'Проверка';
-
- public function handle($arguments)
- {
- Log::info(['tbot' => $arguments]);
- $text = 'Привет';
- $this->replyWithMessage(compact('text'));
- $this->replyWithChatAction(['action' => Actions::TYPING]);
- $telegram_user = \Telegram::getWebhookUpdates()['message'];
- $text = sprintf('%s: %s'.PHP_EOL, 'Ваш номер чата', $telegram_user['from']['id']);
- if (isset($telegram_user['from']['username'])){
- $text .= sprintf('%s: %s'.PHP_EOL, 'Ваше имя пользователя в телеграм', $telegram_user['from']['username']);
- }
- $this->replyWithMessage(compact('text'));
- $updateId = \Telegram::getWebhookUpdates()['update_id']+1;
- \Telegram::getWebhookUpdates(['offset'=>$updateId]);
- }
- }
|