Allow addition of help sections
This commit is contained in:
parent
45e2bbfa3d
commit
aa6f45887e
@ -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.0"
|
||||
__version__ = "2.3.1"
|
||||
__maintainer__ = "Davide Testa"
|
||||
__contact__ = "t.me/davte"
|
||||
|
||||
|
@ -1577,6 +1577,18 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
||||
"""
|
||||
self._unknown_command_message = unknown_command_message
|
||||
|
||||
def add_help_section(self, help_section):
|
||||
"""Add `help_section`."""
|
||||
assert (
|
||||
isinstance(help_section, dict)
|
||||
and 'name' in help_section
|
||||
and 'label' in help_section
|
||||
and 'description' in help_section
|
||||
), "Invalid help section!"
|
||||
if 'authorization_level' not in help_section:
|
||||
help_section['authorization_level'] = 'admin'
|
||||
self.messages['help_sections'][help_section['name']] = help_section
|
||||
|
||||
def command(self, command, aliases=None, reply_keyboard_button=None,
|
||||
show_in_keyboard=False, description="",
|
||||
help_section=None,
|
||||
@ -1641,7 +1653,7 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
||||
if isinstance(help_section, dict):
|
||||
if 'authorization_level' not in help_section:
|
||||
help_section['authorization_level'] = authorization_level
|
||||
self.messages['help_sections'][help_section['name']] = help_section
|
||||
self.add_help_section(help_section)
|
||||
command = command.strip('/ ').lower()
|
||||
|
||||
def command_decorator(command_handler):
|
||||
|
Loading…
x
Reference in New Issue
Block a user