]> apps.delaporte.us Git - matrix-goal-bot.git/blobdiff - matrix_goal_bot/bot.py
Print goal list after adding a goal
[matrix-goal-bot.git] / matrix_goal_bot / bot.py
index 4046eeb39221f92bd56535eaf7e0e7be8ab96d2d..417fca92eb93d99afa23238035b8d7e41a436a21 100644 (file)
@@ -75,8 +75,12 @@ class GoalBot():
         match = botlib.MessageMatch(room, message, self.bot, self.prefix)
 
         if not match.is_not_from_this_bot() and match.prefix():
+            logger.debug(f'Message: {message} was not for this bot.')
             return
 
+        if not match.prefix():
+            logger.debug(f'{message} - did not match {self.prefix}')
+
         if match.prefix():
             try:
                 result_lines = await self._handle_match(match)
@@ -84,11 +88,18 @@ class GoalBot():
                     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))
 
 
     async def _handle_match(self, match):
+        logger.debug(f'Try to match {str(match)}')
 
         if match.command('setup'):
             result = self.data.setup()
@@ -96,10 +107,18 @@ class GoalBot():
 
         if match.command('add'):
             new = ' '.join(match.args()[1:])
-            result = self.data.add_goal(new)
-            return [f'Goal added with id {result}']
+            goal_id = self.data.add_goal(new)
+            results = [f'Goal added with id {goal_id}']
+
+            goals = self.data.get_all_goals()
+            results.append('# Goals list...')
+            for goal in goals:
+                results.append(str(goal))
+
+            return results
 
         if match.command('list'):
+            logger.debug('Asked to list goals...')
             goals = self.data.get_all_goals()
             results = ['# Goals list...']
             for goal in goals: