Commit 4ed9660b authored by Armando Lüscher's avatar Armando Lüscher

ALL commands now return a ServerResponse object instead of a bool.

parent 4fbb6a56
......@@ -31,9 +31,7 @@ class ChatsCommand extends AdminCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -85,6 +83,6 @@ class ChatsCommand extends AdminCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -95,6 +95,6 @@ class SendtoallCommand extends AdminCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -52,8 +52,7 @@ class SendtochannelCommand extends AdminCommand
'text' => $text,
];
$result = Request::sendMessage($data);
if ($result->isOk()) {
if (Request::sendMessage($data)->isOk()) {
$text_back = 'Message sent succesfully to: ' . $your_channel;
} else {
$text_back = 'Sorry message not sent to: ' . $your_channel;
......@@ -65,6 +64,6 @@ class SendtochannelCommand extends AdminCommand
'text' => $text_back,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -122,7 +122,7 @@ abstract class Command
/**
* Pre-execute command
*
* @return mixed
* @return Entities\ServerResponse
*/
public function preExecute()
{
......@@ -134,13 +134,15 @@ abstract class Command
/**
* Execute command
*
* @return Entities\ServerResponse
*/
abstract public function execute();
/**
* Execution if MySQL is required but not available
*
* @return boolean
* @return Entities\ServerResponse
*/
public function executeNoDB()
{
......@@ -153,7 +155,7 @@ abstract class Command
'text' => 'Sorry no database connection, unable to execute "' . $this->name . '" command.',
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
......
......@@ -10,6 +10,8 @@
namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Entities\ServerResponse;
/**
* Abstract System Command Class
*/
......@@ -18,14 +20,14 @@ abstract class SystemCommand extends Command
/**
* A system command just executes
*
* Although system commands should just work and return 'true',
* Although system commands should just work and return a successful ServerResponse,
* each system command can override this method to add custom functionality.
*
* @return bool
* @return Entities\ServerResponse
*/
public function execute()
{
//System command, do nothing
return true;
//System command, return successful ServerResponse
return new ServerResponse(['ok' => true, 'result' => true], null);
}
}
......@@ -26,16 +26,11 @@ class ChannelchatcreatedCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
//System command, do nothing
return true;
}
}*/
}
......@@ -26,18 +26,13 @@ class ChoseninlineresultCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
//Information about chosen result is returned
//$update = $this->getUpdate();
//$inline_query = $update->getChosenInlineResult();
//$query = $inline_query->getQuery();
//System command, do nothing
return true;
}
}*/
}
......@@ -26,16 +26,11 @@ class DeletechatphotoCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
//$message = $this->getMessage();
//$delete_chat_photo = $message->getDeleteChatPhoto();
//System command, do nothing
return true;
}
}*/
}
......@@ -27,9 +27,7 @@ class GenericCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -44,6 +42,6 @@ class GenericCommand extends SystemCommand
'text' => 'Command /' . $command . ' not found.. :(',
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -26,13 +26,10 @@ class GenericmessageCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
//System command, do nothing
return true;
}
}*/
}
......@@ -26,16 +26,11 @@ class GroupchatcreatedCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
//$message = $this->getMessage();
//$group_chat_created = $message->getGroupChatCreated();
//System command, do nothing
return true;
}
}*/
}
......@@ -28,9 +28,7 @@ class InlinequeryCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -52,6 +50,6 @@ class InlinequeryCommand extends SystemCommand
}
$data['results'] = '[' . implode(',', $array_article) . ']';
return Request::answerInlineQuery($data)->isOk();
return Request::answerInlineQuery($data);
}
}
......@@ -26,16 +26,11 @@ class LeftchatparticipantCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
//$message = $this->getMessage();
//$participant = $message->getLeftChatParticipant();
//System command, do nothing
return true;
}
}*/
}
......@@ -27,9 +27,7 @@ class NewchatparticipantCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -49,6 +47,6 @@ class NewchatparticipantCommand extends SystemCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -26,16 +26,11 @@ class NewchattitleCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
/*public function execute()
{
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
//System command, do nothing
return true;
}
}*/
}
......@@ -28,9 +28,7 @@ class StartCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -44,6 +42,6 @@ class StartCommand extends SystemCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -27,9 +27,7 @@ class SupergroupchatcreatedCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -48,6 +46,6 @@ class SupergroupchatcreatedCommand extends SystemCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -175,9 +175,7 @@ class DateCommand extends UserCommand
}
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -204,6 +202,6 @@ class DateCommand extends UserCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -28,9 +28,7 @@ class EchoCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -47,6 +45,6 @@ class EchoCommand extends UserCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -28,9 +28,7 @@ class HelpCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -72,6 +70,6 @@ class HelpCommand extends UserCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -28,9 +28,7 @@ class SlapCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -55,6 +53,6 @@ class SlapCommand extends UserCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -110,9 +110,7 @@ class WeatherCommand extends UserCommand
}
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......@@ -139,6 +137,6 @@ class WeatherCommand extends UserCommand
'text' => $text,
];
return Request::sendMessage($data)->isOk();
return Request::sendMessage($data);
}
}
......@@ -32,9 +32,7 @@ class WhoamiCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public function execute()
{
......
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