]> us-delaporte.pagekite.me Git - matrix-chore-bot.git/blobdiff - matrix_chore_bot/bot.py
Add more snark
[matrix-chore-bot.git] / matrix_chore_bot / bot.py
index c1a76d336464253f3ca51bee7b8f2f48ec9da6e3..acd45c0c248d3366d9b84663ba03c17b614f66e8 100644 (file)
@@ -23,9 +23,21 @@ import simplematrixbotlib as botlib
 from .db import Data as ChoreData
 
 logger = logging.getLogger(__name__)
 from .db import Data as ChoreData
 
 logger = logging.getLogger(__name__)
-logging.basicConfig(filename='matrix-chore-bot.log', encoding='utf-8', level=logging.DEBUG)
 logging.getLogger('nio').setLevel(logging.WARNING)
 
 logging.getLogger('nio').setLevel(logging.WARNING)
 
+snark = [
+    'Ye cannot get ye flask.',
+    'Ye flask must be load bearing, or something...',
+    '''You have:
+        no tea
+    ''',
+    'How are you gentlemen?',
+    'All your base are belong to us.',
+    'You have been eaten by a groo.'
+]
+
+
+
 class ChoreBot():
     def __init__(self, matrix_server,
                  bot_name,
 class ChoreBot():
     def __init__(self, matrix_server,
                  bot_name,
@@ -33,6 +45,9 @@ class ChoreBot():
                  db_file=None,
                  bot_prefix='!chore'):
 
                  db_file=None,
                  bot_prefix='!chore'):
 
+        logging.basicConfig(filename='matrix-chore-bot.log', encoding='utf-8', level=logging.DEBUG)
+
+
         creds = botlib.Creds(matrix_server, bot_name, bot_pwd)
         self.bot = botlib.Bot(creds)
         self.prefix = bot_prefix
         creds = botlib.Creds(matrix_server, bot_name, bot_pwd)
         self.bot = botlib.Bot(creds)
         self.prefix = bot_prefix
@@ -53,6 +68,17 @@ class ChoreBot():
                 for line in result_lines:
                     await self.bot.api.send_text_message(
                         room.room_id, str(line))
                 for line in result_lines:
                     await self.bot.api.send_text_message(
                         room.room_id, str(line))
+
+            except Exception as ex:
+                logger.warn(f'Caught exception: {str(ex)}')
+                dumb_msg_idx = len(str(ex)) % len(snark)
+                dumb_msg = snark[dumb_msg_idx]
+                await self.bot.api.send_text_message(
+                    room.room_id, dumb_msg)
+
+                await self.bot.api.send_text_message(
+                    room.room_id, str(ex))
+
             except Exception as ex:
                 line = f'Ye flask must be load bearing, or something... {str(ex)}'
                 await self.bot.api.send_text_message(
             except Exception as ex:
                 line = f'Ye flask must be load bearing, or something... {str(ex)}'
                 await self.bot.api.send_text_message(