@@ -57,6 +57,11 @@ class CleanupCommand extends AdminCommand
57
57
*/
58
58
protected $ version = '1.0.0 ' ;
59
59
60
+ /**
61
+ * @var bool
62
+ */
63
+ protected $ need_mysql = true ;
64
+
60
65
/**
61
66
* Default tables to clean, cleaning 'chat', 'user' and 'user_chat' by default is bad practice!
62
67
*
@@ -318,6 +323,25 @@ private function getQueries($settings)
318
323
return $ queries ;
319
324
}
320
325
326
+ /**
327
+ * Execution if MySQL is required but not available
328
+ *
329
+ * @return \Longman\TelegramBot\Entities\ServerResponse
330
+ */
331
+ public function executeNoDb ()
332
+ {
333
+ $ message = $ this ->getMessage ();
334
+ $ chat_id = $ message ->getChat ()->getId ();
335
+
336
+ $ data = [
337
+ 'chat_id ' => $ chat_id ,
338
+ 'parse_mode ' => 'Markdown ' ,
339
+ 'text ' => '*No database connection!* ' ,
340
+ ];
341
+
342
+ return Request::sendMessage ($ data );
343
+ }
344
+
321
345
/**
322
346
* Command execute method
323
347
*
@@ -327,20 +351,14 @@ private function getQueries($settings)
327
351
public function execute ()
328
352
{
329
353
$ message = $ this ->getMessage ();
330
- $ chat_id = $ message ->getFrom ()->getId ();
354
+ $ user_id = $ message ->getFrom ()->getId ();
331
355
$ text = $ message ->getText (true );
332
356
333
357
$ data = [
334
- 'chat_id ' => $ chat_id ,
358
+ 'chat_id ' => $ user_id ,
335
359
'parse_mode ' => 'Markdown ' ,
336
360
];
337
361
338
- if (!$ message ->getChat ()->isPrivateChat ()) {
339
- $ data ['text ' ] = '/cleanup command is only available in a private chat. ' ;
340
-
341
- return Request::sendMessage ($ data );
342
- }
343
-
344
362
$ settings = $ this ->getSettings ($ text );
345
363
$ queries = $ this ->getQueries ($ settings );
346
364
0 commit comments