Commit ba2c4b0a authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #566 from jacklul/cleanup_nodb

Cleanup without database...
parents 8a9b0d6f 782eff06
......@@ -57,6 +57,11 @@ class CleanupCommand extends AdminCommand
*/
protected $version = '1.0.0';
/**
* @var bool
*/
protected $need_mysql = true;
/**
* Default tables to clean, cleaning 'chat', 'user' and 'user_chat' by default is bad practice!
*
......@@ -318,6 +323,25 @@ class CleanupCommand extends AdminCommand
return $queries;
}
/**
* Execution if MySQL is required but not available
*
* @return \Longman\TelegramBot\Entities\ServerResponse
*/
public function executeNoDb()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$data = [
'chat_id' => $chat_id,
'parse_mode' => 'Markdown',
'text' => '*No database connection!*',
];
return Request::sendMessage($data);
}
/**
* Command execute method
*
......@@ -327,20 +351,14 @@ class CleanupCommand extends AdminCommand
public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getFrom()->getId();
$user_id = $message->getFrom()->getId();
$text = $message->getText(true);
$data = [
'chat_id' => $chat_id,
'chat_id' => $user_id,
'parse_mode' => 'Markdown',
];
if (!$message->getChat()->isPrivateChat()) {
$data['text'] = '/cleanup command is only available in a private chat.';
return Request::sendMessage($data);
}
$settings = $this->getSettings($text);
$queries = $this->getQueries($settings);
......
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