diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index ce2a9bd..4482608 100644 --- a/davtelepot/__init__.py +++ b/davtelepot/__init__.py @@ -14,7 +14,7 @@ __author__ = "Davide Testa" __email__ = "davide@davte.it" __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __license__ = "GNU General Public License v3.0" -__version__ = "2.1.23" +__version__ = "2.1.24" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/davtelepot/administration_tools.py b/davtelepot/administration_tools.py index a21f174..85eb8dc 100644 --- a/davtelepot/administration_tools.py +++ b/davtelepot/administration_tools.py @@ -502,6 +502,12 @@ default_admin_messages = { 'en': "Restart was successful.", 'it': "Restart avvenuto con successo." } + }, + 'stop_command': { + 'description': { + 'en': "Stop bots", + 'it': "Ferma i bot" + } } } @@ -531,6 +537,11 @@ async def _restart_command(bot, update, user_record): return +async def _stop_command(bot, update, user_record): + bot.__class__.stop(message='=== STOP ===', final_state=0) + return + + def init(bot, talk_messages=None, admin_messages=None, language='en'): """Assign parsers, commands, buttons and queries to given `bot`.""" if talk_messages is None: @@ -626,3 +637,14 @@ def init(bot, talk_messages=None, admin_messages=None, language='en'): ensure=True ) return + + stop_command_description = bot.get_message( + 'admin', 'stop_command', 'description', + language=language + ) + + @bot.command(command='/stop', aliases=[], show_in_keyboard=False, + description=stop_command_description, + authorization_level='admin') + async def stop_command(bot, update, user_record): + return await _stop_command(bot, update, user_record)