Commit f41e8a52 authored by MBoretto's avatar MBoretto

Added code block

parent 521fc159
...@@ -15,6 +15,9 @@ use Longman\TelegramBot\Request; ...@@ -15,6 +15,9 @@ use Longman\TelegramBot\Request;
use Longman\TelegramBot\Commands\UserCommand; use Longman\TelegramBot\Commands\UserCommand;
use Longman\TelegramBot\Entities\ReplyKeyboardHide; use Longman\TelegramBot\Entities\ReplyKeyboardHide;
/**
* User "/cancel" command
*/
class CancelCommand extends UserCommand class CancelCommand extends UserCommand
{ {
/**#@+ /**#@+
...@@ -26,34 +29,40 @@ class CancelCommand extends UserCommand ...@@ -26,34 +29,40 @@ class CancelCommand extends UserCommand
protected $version = '0.1.0'; protected $version = '0.1.0';
/**#@-*/ /**#@-*/
public function executeNoDB() /**
* {@inheritdoc}
*/
public function execute()
{ {
//Database not setted or without connection
$message = $this->getMessage(); $message = $this->getMessage();
$user_id = $message->getFrom()->getId();
$chat_id = $message->getChat()->getId(); $chat_id = $message->getChat()->getId();
//Cancel current conversation if any
(new Conversation($user_id, $chat_id))->cancel();
$data = [ $data = [
'reply_markup' => new ReplyKeyboardHide(['selective' => true]), 'reply_markup' => new ReplyKeyboardHide(['selective' => true]),
'chat_id' => $chat_id, 'chat_id' => $chat_id,
'text' => 'Keyboard hidden!', 'text' => 'Conversation canceled!',
]; ];
return Request::sendMessage($data); return Request::sendMessage($data);
} }
public function execute() /**
* {@inheritdoc}
*/
public function executeNoDB()
{ {
//Database not setted or without connection
$message = $this->getMessage(); $message = $this->getMessage();
$user_id = $message->getFrom()->getId();
$chat_id = $message->getChat()->getId(); $chat_id = $message->getChat()->getId();
//Cancel current conversation if any
(new Conversation($user_id, $chat_id))->cancel();
$data = [ $data = [
'reply_markup' => new ReplyKeyboardHide(['selective' => true]), 'reply_markup' => new ReplyKeyboardHide(['selective' => true]),
'chat_id' => $chat_id, 'chat_id' => $chat_id,
'text' => 'Conversation canceled!', 'text' => 'Keyboard hidden!',
]; ];
return Request::sendMessage($data); 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