Fix example commands.

parent ae619a1b
......@@ -25,7 +25,7 @@ class ForceReplyCommand extends UserCommand
protected $name = 'forcereply';
protected $description = 'Force reply with reply markup';
protected $usage = '/forcereply';
protected $version = '0.0.5';
protected $version = '0.0.6';
/**#@-*/
/**
......@@ -36,10 +36,11 @@ class ForceReplyCommand extends UserCommand
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$data = [];
$data['chat_id'] = $chat_id;
$data['text'] = 'Write something:';
$data['reply_markup'] = new ForceReply(['selective' => false]);
$data = [
'chat_id' => $chat_id,
'text' => 'Write something:',
'reply_markup' => new ForceReply(['selective' => false]),
];
return Request::sendMessage($data);
}
......
......@@ -25,7 +25,7 @@ class ImageCommand extends UserCommand
protected $name = 'image';
protected $description = 'Send Image';
protected $usage = '/image';
protected $version = '1.0.0';
protected $version = '1.0.1';
/**#@-*/
/**
......@@ -37,18 +37,26 @@ class ImageCommand extends UserCommand
$chat_id = $message->getChat()->getId();
$text = $message->getText(true);
$data = [];
$data['chat_id'] = $chat_id;
$data['caption'] = $text;
$data = [
'chat_id' => $chat_id,
'caption' => $text,
];
//return Request::sendPhoto($data, $this->telegram->getUploadPath().'/'.'image.jpg');
//Return a random picture from the telegram->getUploadPath().
return Request::sendPhoto($data, $this->ShowRandomImage($this->telegram->getUploadPath()));
}
//return random picture from the telegram->getUploadPath();
private function ShowRandomImage($dir) {
/**
* Return the path to a random image in the passed directory.
*
* @param string $dir
*
* @return string
*/
private function ShowRandomImage($dir)
{
$image_list = scandir($dir);
return $dir . "/" . $image_list[mt_rand(2, count($image_list) - 1)];
}
return $dir . '/' . $image_list[mt_rand(2, count($image_list) - 1)];
}
}
......@@ -26,7 +26,7 @@ class InlinekeyboardCommand extends UserCommand
protected $name = 'Inlinekeyboard';
protected $description = 'Show inline keyboard';
protected $usage = '/inlinekeyboard';
protected $version = '0.0.1';
protected $version = '0.0.2';
/**#@-*/
/**
......
......@@ -23,9 +23,9 @@ class KeyboardCommand extends UserCommand
* {@inheritdoc}
*/
protected $name = 'keyboard';
protected $description = 'Show a custom keybord with reply markup';
protected $description = 'Show a custom keyboard with reply markup';
protected $usage = '/keyboard';
protected $version = '0.0.6';
protected $version = '0.1.0';
/**#@-*/
/**
......@@ -35,70 +35,67 @@ class KeyboardCommand extends UserCommand
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$text = $message->getText(true);
$data = [];
$data['chat_id'] = $chat_id;
$data['text'] = 'Press a Button:';
$data = [
'chat_id' => $chat_id,
'text' => 'Press a Button:',
];
//Keyboard examples
$keyboards = [];
//0
$keyboard[] = ['7','8','9'];
$keyboard[] = ['4','5','6'];
$keyboard[] = ['1','2','3'];
$keyboard[] = [' ','0',' '];
//Example 0
$keyboard = [];
$keyboard[] = ['7', '8', '9'];
$keyboard[] = ['4', '5', '6'];
$keyboard[] = ['1', '2', '3'];
$keyboard[] = [' ', '0', ' '];
$keyboards[] = $keyboard;
unset($keyboard);
//1
$keyboard[] = ['7','8','9','+'];
$keyboard[] = ['4','5','6','-'];
$keyboard[] = ['1','2','3','*'];
$keyboard[] = [' ','0',' ','/'];
//Example 1
$keyboard = [];
$keyboard[] = ['7', '8', '9', '+'];
$keyboard[] = ['4', '5', '6', '-'];
$keyboard[] = ['1', '2', '3', '*'];
$keyboard[] = [' ', '0', ' ', '/'];
$keyboards[] = $keyboard;
unset($keyboard);
//2
//Example 2
$keyboard = [];
$keyboard[] = ['A'];
$keyboard[] = ['B'];
$keyboard[] = ['C'];
$keyboards[] = $keyboard;
unset($keyboard);
//3
//Example 3
$keyboard = [];
$keyboard[] = ['A'];
$keyboard[] = ['B'];
$keyboard[] = ['C','D'];
$keyboard[] = ['C', 'D'];
$keyboards[] = $keyboard;
unset($keyboard);
//4 (bots 2.0)
//Example 4 (bots version 2.0)
$keyboard = [];
$keyboard[] = [
[
'text' => 'request_contact',
'request_contact' => true
'text' => 'Send my contact',
'request_contact' => true,
],
[
'text' => 'request_location',
'request_location' => true
]
'text' => 'Send my location',
'request_location' => true,
],
];
$keyboards[] = $keyboard;
unset($keyboard);
//Return a random keyboard.
$keyboard = $keyboards[mt_rand(0, count($keyboards) - 1)];
$data['reply_markup'] = new ReplyKeyboardMarkup(
[
'keyboard' => $keyboards[1] ,
'keyboard' => $keyboard,
'resize_keyboard' => true,
'one_time_keyboard' => false,
'selective' => false
'selective' => false,
]
);
......
......@@ -25,7 +25,7 @@ class MarkdownCommand extends UserCommand
protected $name = 'markdown';
protected $description = 'Print Markdown tesxt';
protected $usage = '/markdown';
protected $version = '1.0.0';
protected $version = '1.0.1';
/**#@-*/
/**
......@@ -35,17 +35,18 @@ class MarkdownCommand extends UserCommand
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$text = $message->getText(true);
$data = [];
$data['chat_id'] = $chat_id;
$data['parse_mode'] = 'MARKDOWN';
$data['text'] = "*bold* _italic_ `inline fixed width code` ```preformatted code block
$data = [
'chat_id' => $chat_id,
'parse_mode' => 'MARKDOWN',
'text' => '*bold* _italic_ `inline fixed width code`
```
preformatted code block
code block
```
[Best Telegram bot api!!](https://github.com/akalongman/php-telegram-bot)
";
',
];
return Request::sendMessage($data);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment