Allow command aliases to be a /command too.

This commit is contained in:
Davte 2019-12-01 18:20:39 +01:00
parent d30ed21de2
commit e7a30d0369
2 changed files with 8 additions and 2 deletions

View File

@ -14,7 +14,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.3.6" __version__ = "2.3.7"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -1696,7 +1696,13 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
) )
if aliases: if aliases:
for alias in 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): if show_in_keyboard and (aliases or reply_keyboard_button):
_reply_keyboard_button = reply_keyboard_button or aliases[0] _reply_keyboard_button = reply_keyboard_button or aliases[0]
self.messages[ self.messages[