From e7a30d0369ee3f93b4dba5a1a3556714fa5329e8 Mon Sep 17 00:00:00 2001 From: Davte Date: Sun, 1 Dec 2019 18:20:39 +0100 Subject: [PATCH] Allow command aliases to be a `/command` too. --- davtelepot/__init__.py | 2 +- davtelepot/bot.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index 8332453..dab8d70 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.3.6" +__version__ = "2.3.7" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/davtelepot/bot.py b/davtelepot/bot.py index 420b47b..273cc08 100644 --- a/davtelepot/bot.py +++ b/davtelepot/bot.py @@ -1696,7 +1696,13 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject): ) if aliases: for alias in aliases: - self.command_aliases[alias] = decorated_command_handler + if alias.startswith('/'): + self.commands[alias.strip('/ ').lower()] = dict( + handler=decorated_command_handler, + authorization_level=authorization_level + ) + else: + self.command_aliases[alias] = decorated_command_handler if show_in_keyboard and (aliases or reply_keyboard_button): _reply_keyboard_button = reply_keyboard_button or aliases[0] self.messages[