StartCommand.php 1.21 KB
Newer Older
1
<?php
2
/**
3 4 5 6 7 8
 * This file is part of the TelegramBot package.
 *
 * (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
9 10
 */

11
namespace Longman\TelegramBot\Commands\SystemCommands;
12

13
use Longman\TelegramBot\Commands\SystemCommand;
14
use Longman\TelegramBot\Request;
15

16 17 18
/**
 * Start command
 */
19
class StartCommand extends SystemCommand
20
{
21 22
    /**
     * @var string
23
     */
24
    protected $name = 'start';
25 26 27 28

    /**
     * @var string
     */
29
    protected $description = 'Start command';
30 31 32 33

    /**
     * @var string
     */
34
    protected $usage = '/start';
35 36 37 38

    /**
     * @var string
     */
39
    protected $version = '1.1.0';
40

41
    /**
42 43 44
     * Command execute method
     *
     * @return mixed
45
     * @throws \Longman\TelegramBot\Exception\TelegramException
46
     */
47 48 49 50 51
    public function execute()
    {
        $message = $this->getMessage();

        $chat_id = $message->getChat()->getId();
52
        $text    = 'Hi there!' . PHP_EOL . 'Type /help to see all commands!';
53

54 55 56 57
        $data = [
            'chat_id' => $chat_id,
            'text'    => $text,
        ];
58

59
        return Request::sendMessage($data);
60 61
    }
}