Queer European MD passionate about IT
Browse Source

Multilanguage support for unknown command and authorization denied messages

Davte 4 years ago
parent
commit
0f5ca87947
3 changed files with 14 additions and 5 deletions
  1. 1 1
      ciclopibot/__init__.py
  2. 3 4
      ciclopibot/bot.py
  3. 10 0
      ciclopibot/messages.py

+ 1 - 1
ciclopibot/__init__.py

@@ -3,7 +3,7 @@
 __author__ = "Davide Testa"
 __email__ = "davide@davte.it"
 __license__ = "GNU General Public License v3.0"
-__version__ = "1.1.12"
+__version__ = "1.1.13"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"
 

+ 3 - 4
ciclopibot/bot.py

@@ -9,7 +9,7 @@ import sys
 import davtelepot
 
 # Project modules
-from . import ciclopi
+from . import ciclopi, messages
 from .data.passwords import bot_token
 from .messages import (
     default_help_messages, language_messages, supported_languages
@@ -73,11 +73,10 @@ if __name__ == '__main__':
     bot.set_class_log_file_name(log_file_name)
     bot.set_class_errors_file_name(errors_file_name)
     bot.set_unknown_command_message(
-        "Comando sconosciuto!\n"
-        "Scrivi /help per visualizzare la guida."
+        messages.unknown_command_message
     )
     bot.set_authorization_denied_message(
-        "Non disponi di autorizzazioni sufficienti per questo comando."
+        messages.authorization_denied_message
     )
     with bot.db as db:
         db['users'].upsert(

+ 10 - 0
ciclopibot/messages.py

@@ -1,5 +1,10 @@
 """Default messages for bot functions."""
 
+authorization_denied_message = {
+    'en': "You are not allowed to use this command, sorry.",
+    'it': "Non disponi di autorizzazioni sufficienti per questa richiesta, spiacente.",
+}
+
 language_messages = {
     'language_command': {
         'name': {
@@ -496,3 +501,8 @@ default_help_messages = {
             'it': "Comandi 🤖",
     },
 }
+
+unknown_command_message = {
+    'en': "Unknown command! Touch /help to read the guide and available commands.",
+    'it': "Comando sconosciuto! Fai /help per leggere la guida e i comandi."
+}