1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\TCommands;
- use Illuminate\Support\Facades\Log;
- use Telegram\Bot\Actions;
- use Telegram\Bot\Commands\Command;
- /**
- * Class TestCommand.
- */
- class TestCommand extends Command
- {
- /**
- * @var string Command Name
- */
- protected $name = 'test';
- /**
- * @var array Command Aliases
- */
- protected $aliases = ['listcommands'];
- /**
- * @var string Command Description
- */
- protected $description = 'Проверка';
- /**
- * {@inheritdoc}
- */
- public function handle($arguments)
- {
- Log::info(['tbot' => $arguments]);
- $text = 'Привет';
- $this->replyWithMessage(compact('text'));
- $this->replyWithChatAction(['action' => Actions::TYPING]);
- $telegram_user = \Telegram::getWebhookUpdates()['message'];
- // Log::info([$telegram_user]);
- //
- $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']);
- }
- // Log::info($text);
- $this->replyWithMessage(compact('text'));
- $updateId = \Telegram::getWebhookUpdates()['update_id']+1;
- \Telegram::getWebhookUpdates(['offset'=>$updateId]);
- }
- }
|