]> apps.delaporte.us Git - matrix-goal-bot.git/commitdiff
Fix for task removal
authorEdward Delaporte <edward@delaporte.us>
Wed, 8 Apr 2026 23:07:14 +0000 (18:07 -0500)
committerEdward Delaporte <edward@delaporte.us>
Wed, 8 Apr 2026 23:07:14 +0000 (18:07 -0500)
matrix_goal_bot/bot.py
matrix_goal_bot/db.py

index 417fca92eb93d99afa23238035b8d7e41a436a21..47c71a365b46e8a2e646fd9515881c991b6335d1 100644 (file)
@@ -71,13 +71,13 @@ class GoalBot():
         self.bot.run()
 
     async def handle_message(self, room, message):
-        logger.debug(f'Message: {message}')
         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.')
+        if not match.is_not_from_this_bot():
+            # Let's not talk to our-self
             return
 
+        logger.debug(f'Message: {message}')
         if not match.prefix():
             logger.debug(f'{message} - did not match {self.prefix}')
 
index bc8cdbc4cff1ef941c45bc9e39ddf4ad3b56db64..6421d2bdb3aad8141dae7e52d42b2d61872ec084 100644 (file)
@@ -204,9 +204,14 @@ class Data():
 
     def remove_task(self, task_id):
         task_name = ''
+        logger.debug(f'Removing task with id {task_id}')
         with Session(self.engine) as session:
-            cmd = select(Task).where(Task.id  == task_id)
+            cmd = select(Task).where(Task.id  == int(task_id))
             to_remove = session.exec(cmd).first()
+            if not to_remove:
+                return f'Unable to find task with id {task_id}'
+
+            logger.debug(f'Removing task with name {to_remove.name}')
             task_name = to_remove.name
             session.delete(to_remove)
             session.commit()