Completed
Pull Request — develop (#288)
by Armando
30:59 queued 27:12
created

InlinekeyboardCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 5
dl 0
loc 32
rs 10
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Commands\UserCommands;
12
13
use Longman\TelegramBot\Commands\UserCommand;
14
use Longman\TelegramBot\Request;
15
use Longman\TelegramBot\Entities\InlineKeyboardMarkup;
16
use Longman\TelegramBot\Entities\InlineKeyboardButton;
17
18
/**
19
 * User "/inlinekeyboard" command
20
 */
21
class InlinekeyboardCommand extends UserCommand
22
{
23
    /**#@+
24
     * {@inheritdoc}
25
     */
26
    protected $name = 'Inlinekeyboard';
27
    protected $description = 'Show inline keyboard';
28
    protected $usage = '/inlinekeyboard';
29
    protected $version = '0.0.2';
30
    /**#@-*/
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function execute()
36
    {
37
        $message = $this->getMessage();
38
39
        $inline_keyboard = [
40
            new InlineKeyboardButton(['text' => 'inline', 'switch_inline_query' => 'true']),
41
            new InlineKeyboardButton(['text' => 'callback', 'callback_data' => 'identifier']),
42
            new InlineKeyboardButton(['text' => 'open url', 'url' => 'https://github.com/akalongman/php-telegram-bot']),
43
        ];
44
        $data            = [
45
            'chat_id'      => $message->getChat()->getId(),
46
            'text'         => 'inline keyboard',
47
            'reply_markup' => new InlineKeyboardMarkup(['inline_keyboard' => [$inline_keyboard]]),
48
        ];
49
50
        return Request::sendMessage($data);
51
    }
52
}
53