Multilanguage support for unknown command and authorization denied messages

This commit is contained in:
Davte 2020-03-11 09:59:16 +01:00
parent 757fa158b6
commit 0f5ca87947
3 changed files with 14 additions and 5 deletions

View File

@ -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"

View File

@ -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(

View File

@ -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."
}