Commit fba22125 authored by Armando Lüscher's avatar Armando Lüscher

Clean Admin commands, removing all unnecessary or unused code.

parent a35d2cec
......@@ -13,8 +13,6 @@ namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Command;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\Chat;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
/**
......@@ -50,13 +48,6 @@ class ChatsCommand extends Command
*/
protected $version = '1.0.0';
/**
* If this command is enabled
*
* @var boolean
*/
protected $enabled = true;
/**
* If this command is public
*
......@@ -81,12 +72,13 @@ class ChatsCommand extends Command
//Preparing message
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$data = [
'chat_id' => $chat_id,
'text' => 'Sorry no database connection, unable to execute "' . $this->name . '" command.',
];
$result = Request::sendMessage($data);
return $result->isOk();
return Request::sendMessage($data)->isOk();
}
/**
......@@ -96,12 +88,9 @@ class ChatsCommand extends Command
*/
public function execute()
{
$update = $this->getUpdate();
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$message_id = $message->getMessageId();
$text = $message->getText(true);
$results = DB::selectChats(
true, //Send to groups (group chat)
......@@ -133,7 +122,7 @@ class ChatsCommand extends Command
}
}
if (($user_chats + $group_chats + $super_group_chats) == 0) {
if (($user_chats + $group_chats + $super_group_chats) === 0) {
$text = 'No chats found..';
} else {
$text .= "\n" . 'Private Chats: ' . $user_chats;
......@@ -146,7 +135,7 @@ class ChatsCommand extends Command
'chat_id' => $chat_id,
'text' => $text,
];
$result = Request::sendMessage($data);
return $result->isOk();
return Request::sendMessage($data)->isOk();
}
}
......@@ -11,9 +11,6 @@
namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Command;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
/**
......@@ -49,13 +46,6 @@ class SendtoallCommand extends Command
*/
protected $version = '1.2.0';
/**
* If this command is enabled
*
* @var boolean
*/
protected $enabled = true;
/**
* If this command is public
*
......@@ -80,12 +70,13 @@ class SendtoallCommand extends Command
//Preparing message
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$data = [
'chat_id' => $chat_id,
'text' => 'Sorry no database connection, unable to execute "' . $this->name . '" command.',
];
$result = Request::sendMessage($data);
return $result->isOk();
return Request::sendMessage($data)->isOk();
}
/**
......@@ -97,12 +88,9 @@ class SendtoallCommand extends Command
*/
public function execute()
{
$update = $this->getUpdate();
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$message_id = $message->getMessageId();
$text = $message->getText(true);
if (empty($text)) {
$text = 'Write the message to send: /sendall <message>';
......@@ -147,7 +135,7 @@ class SendtoallCommand extends Command
}
$text .= 'Delivered: ' . ($tot - $fail) . '/' . $tot . "\n";
}
if ($tot == 0) {
if ($tot === 0) {
$text = 'No users or chats found..';
}
......@@ -156,7 +144,6 @@ class SendtoallCommand extends Command
'text' => $text,
];
$result = Request::sendMessage($data);
return $result->isOk();
return Request::sendMessage($data)->isOk();
}
}
......@@ -11,9 +11,6 @@
namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Command;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
/**
......@@ -49,13 +46,6 @@ class SendtochannelCommand extends Command
*/
protected $version = '0.1.0';
/**
* If this command is enabled
*
* @var boolean
*/
protected $enabled = true;
/**
* If this command is public
*
......@@ -79,11 +69,9 @@ class SendtochannelCommand extends Command
*/
public function execute()
{
$update = $this->getUpdate();
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$message_id = $message->getMessageId();
$text = $message->getText(true);
if (empty($text)) {
......@@ -109,7 +97,6 @@ class SendtochannelCommand extends Command
'text' => $text_back,
];
$result = Request::sendMessage($data);
return $result->isOk();
return Request::sendMessage($data)->isOk();
}
}
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