Update default help messages with given ones, instead of replacing them

This commit is contained in:
Davte 2020-07-17 09:48:39 +02:00
parent 8c37d00602
commit 88835955ef
2 changed files with 9 additions and 3 deletions

View File

@ -11,7 +11,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.6.8" __version__ = "2.6.9"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -5,7 +5,8 @@ from .bot import Bot
from .messages import default_help_messages from .messages import default_help_messages
from .utilities import ( from .utilities import (
get_cleaned_text, make_inline_keyboard, get_cleaned_text, make_inline_keyboard,
make_lines_of_buttons, make_button make_lines_of_buttons, make_button,
recursive_dictionary_update
) )
@ -245,10 +246,15 @@ async def _start_command(bot, update, user_record):
return return
def init(telegram_bot, help_messages=None): def init(telegram_bot: Bot, help_messages: dict = None):
"""Assign parsers, commands, buttons and queries to given `bot`.""" """Assign parsers, commands, buttons and queries to given `bot`."""
if help_messages is None: if help_messages is None:
help_messages = default_help_messages help_messages = default_help_messages
else:
help_messages = recursive_dictionary_update(
default_help_messages.copy(),
help_messages.copy()
)
telegram_bot.messages['help'] = help_messages telegram_bot.messages['help'] = help_messages
@telegram_bot.command("/start", authorization_level='everybody') @telegram_bot.command("/start", authorization_level='everybody')