Commit e44202be authored by MBoretto's avatar MBoretto

Uptodate reply markup tipes

parent e41966bb
......@@ -14,7 +14,10 @@ namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Entities\ReplyMarkup;
use Longman\TelegramBot\Entities\ReplyKeyboardMarkup;
use Longman\TelegramBot\Entities\ReplyKeyboardHide;
use Longman\TelegramBot\Entities\ForceReply;
class ForceReplyCommand extends Command
{
......@@ -38,14 +41,18 @@ class ForceReplyCommand extends Command
$data['text'] = 'Write something:';
#$data['reply_to_message_id'] = $message_id;
$markup = new ReplyMarkup;
//$markup->addForceReply($selective = false)
$markup->addForceReply(false);
$json = (
new ForceReply(
array(
'selective' => false
)
)
)->toJSON();
$json = $markup->getJsonQuery();
#echo $json;
$data['reply_markup'] = $json;
$result = Request::sendMessage($data);
return $result;
}
......
......@@ -14,7 +14,10 @@ namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Entities\ReplyMarkup;
use Longman\TelegramBot\Entities\ReplyKeyboardMarkup;
use Longman\TelegramBot\Entities\ReplyKeyboardHide;
use Longman\TelegramBot\Entities\ForceReply;
class HidekeyboardCommand extends Command
{
......@@ -38,10 +41,14 @@ class HidekeyboardCommand extends Command
$data['text'] = 'Keyboard Hided';
#$data['reply_to_message_id'] = $message_id;
$markup = new ReplyMarkup;
//$markup->addKeyBoardHide($selective = false){
$markup->addKeyBoardHide(false);
$json = $markup->getJsonQuery();
$json = (
new ReplyKeyBoardHide(
array(
'selective' => false
)
)
)->toJSON();
$data['reply_markup'] = $json;
$result = Request::sendMessage($data);
......
......@@ -14,7 +14,10 @@ namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Entities\ReplyMarkup;
use Longman\TelegramBot\Entities\ReplyKeyboardMarkup;
use Longman\TelegramBot\Entities\ReplyKeyboardHide;
use Longman\TelegramBot\Entities\ForceReply;
class KeyboardCommand extends Command
{
......@@ -39,24 +42,59 @@ class KeyboardCommand extends Command
#$data['reply_to_message_id'] = $message_id;
$markup = new ReplyMarkup;
//$markup->addKeyBoard($options,$resize=false,$once=false,$selective=false)
//onother keyboard example
#$markup->addKeyBoard(array('A','B','C'),true,false,false);
//onother keyboard example
#$markup->addKeyBoard(array('A',array('B','B1'),'C'),true,false,false);
#Keyboard examples
$keyboards = array();
//0
$keyboard[0] = array('7','8','9');
$keyboard[1] = array('4','5','6');
$keyboard[2] = array('1','2','3');
$keyboard[3] = array(' ','0',' ');
$keyboards[] = $keyboard;
unset($keyboard);
//1
$keyboard[0] = array('7','8','9','+');
$keyboard[1] = array('4','5','6','-');
$keyboard[2] = array('1','2','3','*');
$keyboard[3] = array(' ','0',' ','/');
$keyboards[] = $keyboard;
unset($keyboard);
//2
$keyboard[0] = array('A');
$keyboard[1] = array('B');
$keyboard[2] = array('C');
$keyboards[] = $keyboard;
unset($keyboard);
//3
$keyboard[0] = array('A');
$keyboard[1] = array('B');
$keyboard[2] = array('C','D');
$keyboards[] = $keyboard;
unset($keyboard);
$markup->addKeyBoard(array(
array('7','8','9'),
array('4','5','6'),
array('1','2','3'),
array('0')
), true, false, false);
$json = $markup->getJsonQuery();
$json = (
new ReplyKeyboardMarkup(
array(
'keyboard' => $keyboards[1] ,
'resize_keyboard' => true,
'one_time_keyboard' => false,
'selective' => false
)
)
)->toJSON();
#echo $json;
$data['reply_markup'] = $json;
$result = Request::sendMessage($data);
......
<?php
/*
* 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.
* Written by Marco Boretto <marco.bore@gmail.com>
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class ForceReply extends Entity
{
protected $force_reply;
protected $selective;
public function __construct(array $data = null)
{
$this->force_reply = true;
$this->selective = isset($data['selective']) ? $data['selective'] : false;
}
}
<?php
/*
* 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.
* Written by Marco Boretto <marco.bore@gmail.com>
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class ReplyKeyboardHide extends Entity
{
protected $hide_keyboard;
protected $selective;
public function __construct(array $data = null)
{
$this->hide_keyboard = true;
$this->selective = isset($data['selective']) ? $data['selective'] : false;
}
}
<?php
/*
* 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.
* Written by Marco Boretto <marco.bore@gmail.com>
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class ReplyKeyboardMarkup extends Entity
{
protected $keyboard;
protected $resize_keyboard;
protected $one_time_keyboard;
protected $selective;
public function __construct($data = array())
{
if (isset($data['keyboard'])) {
if (is_array($data['keyboard'])) {
foreach ($data['keyboard'] as $item) {
if (!is_array($item)) {
throw new TelegramException('Keyboard subfield is not an array!');
}
}
$this->keyboard = $data['keyboard'];
} else {
throw new TelegramException('Keyboard field is not an array!');
}
} else {
throw new TelegramException('Keyboard field is empty!');
}
$this->resize_keyboard = isset($data['resize_keyboard']) ? $data['resize_keyboard'] : false;
$this->one_time_keyboard = isset($data['one_time_keyboard']) ? $data['one_time_keyboard'] : false;
$this->selective = isset($data['selective']) ? $data['selective'] : false;
}
}
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