Queer European MD passionate about IT
Browse Source

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

Davte 3 years ago
parent
commit
88835955ef
2 changed files with 9 additions and 3 deletions
  1. 1 1
      davtelepot/__init__.py
  2. 8 2
      davtelepot/helper.py

+ 1 - 1
davtelepot/__init__.py

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

+ 8 - 2
davtelepot/helper.py

@@ -5,7 +5,8 @@ from .bot import Bot
 from .messages import default_help_messages
 from .utilities import (
     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
 
 
-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`."""
     if help_messages is None:
         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.command("/start", authorization_level='everybody')