Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
ba2c4b0a
Commit
ba2c4b0a
authored
Aug 06, 2017
by
Armando Lüscher
Committed by
GitHub
Aug 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #566 from jacklul/cleanup_nodb
Cleanup without database...
parents
8a9b0d6f
782eff06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
CleanupCommand.php
src/Commands/AdminCommands/CleanupCommand.php
+26
-8
No files found.
src/Commands/AdminCommands/CleanupCommand.php
View file @
ba2c4b0a
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment