Queer European MD passionate about IT
Browse Source

Send error message if database could not be sent

Davte 4 years ago
parent
commit
1c76c7d797
2 changed files with 15 additions and 15 deletions
  1. 2 6
      davtelepot/administration_tools.py
  2. 13 9
      davtelepot/messages.py

+ 2 - 6
davtelepot/administration_tools.py

@@ -544,13 +544,9 @@ async def _send_bot_database(bot: Bot, user_record: OrderedDict, language: str):
             language=language
         )
     )
-    if isinstance(sent_update, Exception):
-        return bot.get_message(
-            'admin', 'db_command', 'db_sent',
-            language=language
-        )
     return bot.get_message(
-        'admin', 'db_command', 'db_sent',
+        'admin', 'db_command',
+        ('error' if isinstance(sent_update, Exception) else 'db_sent'),
         language=language
     )
 

+ 13 - 9
davtelepot/messages.py

@@ -37,9 +37,21 @@ default_admin_messages = {
         'it': "🔄 Clicka di nuovo per confermare",
     },
     'db_command': {
+        'db_sent': {
+            'en': "Database sent.",
+            'it': "Database inviato.",
+        },
         'description': {
             'en': "Ask for bot database via Telegram",
-            'it': "Ricevi il database del bot via Telegram"
+            'it': "Ricevi il database del bot via Telegram",
+        },
+        'error': {
+            'en': "Error sending database.",
+            'it': "Errore durante l'invio del database.",
+        },
+        'file_caption': {
+            'en': "Here is bot database.",
+            'it': "Ecco il database!"
         },
         'not_sqlite': {
             'en': "Only SQLite databases may be sent via Telegram, since they "
@@ -49,14 +61,6 @@ default_admin_messages = {
                   "in quanto composti di un solo file.\n"
                   "Questo bot ha invece un database `{db_type}`."
         },
-        'file_caption': {
-            'en': "Here is bot database.",
-            'it': "Ecco il database!"
-        },
-        'db_sent': {
-            'en': "Database sent.",
-            'it': "Database inviato."
-        }
     },
     'error': {
         'text': {