Fix and improve System commands.

parent e67d9b73
......@@ -31,12 +31,13 @@ class CallbackqueryCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.0';
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
......@@ -45,15 +46,11 @@ class CallbackqueryCommand extends SystemCommand
$callback_query_id = $callback_query->getId();
$callback_data = $callback_query->getData();
$data['callback_query_id'] = $callback_query_id;
if ($callback_data == 'thumb up') {
$data['text'] = 'Hello World!';
$data['show_alert'] = true;
} else {
$data['text'] = 'Hello World!';
$data['show_alert'] = false;
}
$data = [
'callback_query_id' => $callback_query_id,
'text' => 'Hello World!',
'show_alert' => $callback_data === 'thumb up',
];
return Request::answerCallbackQuery($data);
}
......
......@@ -30,11 +30,19 @@ class ChannelchatcreatedCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
}*/
return parent::execute();
}
}
......@@ -30,13 +30,21 @@ class ChoseninlineresultCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//Information about chosen result is returned
//$update = $this->getUpdate();
//$inline_query = $update->getChosenInlineResult();
//$query = $inline_query->getQuery();
}*/
return parent::execute();
}
}
......@@ -30,11 +30,19 @@ class DeletechatphotoCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$delete_chat_photo = $message->getDeleteChatPhoto();
}*/
return parent::execute();
}
}
......@@ -30,11 +30,19 @@ class EditedmessageCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.0';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$update = $this->getUpdate();
$edited_message = $update->getEditedMessage();
}*/
//$update = $this->getUpdate();
//$edited_message = $update->getEditedMessage();
return parent::execute();
}
}
......@@ -31,12 +31,13 @@ class GenericCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
......@@ -47,8 +48,9 @@ class GenericCommand extends SystemCommand
$user_id = $message->getFrom()->getId();
$command = $message->getCommand();
if (in_array($user_id, $this->telegram->getAdminList()) && strtolower(substr($command, 0, 5)) == 'whois') {
return $this->telegram->executeCommand('whois', $this->update);
//If the user is and admin and the command is in the format "/whoisXYZ", call the /whois command
if (stripos($command, 'whois') === 0 && $this->telegram->isAdmin($user_id)) {
return $this->telegram->executeCommand('whois');
}
$data = [
......
......@@ -32,7 +32,7 @@ class GenericmessageCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.2';
protected $version = '1.1.0';
/**
* @var bool
......@@ -54,6 +54,7 @@ class GenericmessageCommand extends SystemCommand
* Execute command
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
......@@ -64,7 +65,7 @@ class GenericmessageCommand extends SystemCommand
);
//Fetch conversation command if it exists and execute it
if ($conversation->exists() && ($command = $conversation->getCommand())) {
return $this->telegram->executeCommand($command, $this->update);
return $this->telegram->executeCommand($command);
}
return Request::emptyResponse();
......
......@@ -30,11 +30,19 @@ class GroupchatcreatedCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$group_chat_created = $message->getGroupChatCreated();
}*/
return parent::execute();
}
}
......@@ -33,12 +33,13 @@ class InlinequeryCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.2';
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
......@@ -55,19 +56,19 @@ class InlinequeryCommand extends SystemCommand
'id' => '001',
'title' => 'https://core.telegram.org/bots/api#answerinlinequery',
'description' => 'you enter: ' . $query,
'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query])
'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query]),
],
[
'id' => '002',
'title' => 'https://core.telegram.org/bots/api#answerinlinequery',
'description' => 'you enter: ' . $query,
'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query])
'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query]),
],
[
'id' => '003',
'title' => 'https://core.telegram.org/bots/api#answerinlinequery',
'description' => 'you enter: ' . $query,
'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query])
'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query]),
],
];
......
......@@ -30,11 +30,19 @@ class LeftchatmemberCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$member = $message->getLeftChatMember();
}*/
return parent::execute();
}
}
......@@ -30,11 +30,19 @@ class MigratefromchatidCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$migrate_from_chat_id = $message->getMigrateFromChatId();
}*/
return parent::execute();
}
}
......@@ -30,11 +30,19 @@ class MigratetochatidCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$migrate_to_chat_id = $message->getMigrateToChatId();
}*/
return parent::execute();
}
}
......@@ -31,10 +31,13 @@ class NewchatmemberCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
......@@ -42,10 +45,9 @@ class NewchatmemberCommand extends SystemCommand
$chat_id = $message->getChat()->getId();
$member = $message->getNewChatMember();
if ($message->botAddedInChat()) {
$text = 'Hi there!';
} else {
if (!$message->botAddedInChat()) {
$text = 'Hi ' . $member->tryMention() . '!';
}
......
......@@ -30,11 +30,19 @@ class NewchatphotoCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$new_chat_photo = $message->getNewChatPhoto();
}*/
return parent::execute();
}
}
......@@ -30,11 +30,19 @@ class NewchattitleCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
}*/
return parent::execute();
}
}
......@@ -36,19 +36,20 @@ class StartCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$text = 'Hi there!' . "\n" . 'Type /help to see all commands!';
$text = 'Hi there!' . PHP_EOL . 'Type /help to see all commands!';
$data = [
'chat_id' => $chat_id,
......
......@@ -30,11 +30,19 @@ class SupergroupchatcreatedCommand extends SystemCommand
/**
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.1.0';
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$supergroup_chat_created = $message->getSuperGroupChatCreated();
}*/
return parent::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