Hitmare

MenuCommand.php

Dec 24th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2. /**
  3.  * This file is part of the TelegramBot package.
  4.  *
  5.  * (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
  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. use Longman\TelegramBot\Commands\UserCommand;
  13. use Longman\TelegramBot\Entities\InlineKeyboard;
  14. use Longman\TelegramBot\Request;
  15. /**
  16.  * User "/inlinekeyboard" command
  17.  */
  18. class MenuCommand extends UserCommand
  19. {
  20.  
  21.     /**
  22.      * @var string
  23.      */
  24.     protected $name = 'menu';
  25.  
  26.     /**
  27.      * @var string
  28.      */
  29.     protected $description = 'Inline Keyboard Menu structure';
  30.  
  31.     /**
  32.      * @var string
  33.      */
  34.     protected $usage = '/menu';
  35.  
  36.     /**
  37.      * @var string
  38.      */
  39.     protected $version = '0.0.1';
  40.  
  41.     /**
  42.      * Command execute method
  43.      *
  44.      * @return \Longman\TelegramBot\Entities\ServerResponse
  45.      * @throws \Longman\TelegramBot\Exception\TelegramException
  46.      */
  47.     public function execute()
  48.     {
  49.         $message = $this->getMessage();
  50.     $chat_id    = $message->getChat()->getId();
  51.    
  52.         $inline_keyboard = new InlineKeyboard(
  53.        
  54.         [
  55.             ['text' => 'Menu1', 'callback_data' => 'menu1'],
  56.         ],
  57.         [
  58.             ['text' => 'Menu2', 'callback_data' => 'menu2'],
  59.         ],[
  60.             ['text' => '[Delete Post]', 'callback_data' => 'del-msg'],
  61.            
  62.         ]);
  63.        
  64.  
  65.         $data = [
  66.             'chat_id'      => $chat_id,
  67.             'text'         => 'Menu',
  68.             'reply_markup' => $inline_keyboard,
  69.         ];
  70.  
  71.         return Request::sendMessage($data);
  72.        
  73.        
  74.     }
  75.    
  76. }
  77.    
  78. ?>
Add Comment
Please, Sign In to add comment