From: Edward Delaporte Date: Wed, 8 Apr 2026 22:07:03 +0000 (-0500) Subject: Rebasing X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-goal-bot.git/commitdiff_plain/913b65b598c1a233cce4f69724b4aca8ca6ef02a Rebasing --- diff --git a/matrix_goal_bot/bot.py b/matrix_goal_bot/bot.py index fd8fdca..37cb90d 100644 --- a/matrix_goal_bot/bot.py +++ b/matrix_goal_bot/bot.py @@ -10,9 +10,6 @@ SERVER = os.environ.get('MATRIX_SERVER') BOT_NAME = os.environ.get('GOAL_BOT') BOT_PWD = os.environ.get('GOAL_BOT_PWD') -def get_bot(): - creds = botlib.Creds(SERVER, BOT_NAME, BOT_PWD) - return botlib.Bot(creds) DATE_FORMAT = '%Y-%m-%d' @@ -177,6 +174,11 @@ async def do_goal(match): results = pretty_print(goal, tasks) return results + if match.command('remove'): + task_id = int(match.args()[1]) + result = Data().remove_task(task_id) + return [result] + if match.command('extra.help'): return [ex_help] diff --git a/matrix_goal_bot/db.py b/matrix_goal_bot/db.py index 9ab3898..6a73021 100644 --- a/matrix_goal_bot/db.py +++ b/matrix_goal_bot/db.py @@ -205,6 +205,16 @@ class Data(): session.commit() return goal_id + def remove_task(self, task_id): + task_name = '' + with Session(self.engine) as session: + cmd = select(Task).where(Task.id == task_id) + to_remove = session.exec(cmd).first() + task_name = to_remove.name + session.delete(to_remove) + session.commit() + return f'Removed task "{task_name}"' + def assign_vision(self, goal_id, vision_id): '''Goals may move between visions''' self._set_pref_goal_id(goal_id) diff --git a/matrix_goal_bot/tasks.py b/matrix_goal_bot/tasks.py index 5eb9bf7..be2004f 100644 --- a/matrix_goal_bot/tasks.py +++ b/matrix_goal_bot/tasks.py @@ -29,6 +29,12 @@ def add_task(c, goal_id, name): result = Data().add_task(goal_id=goal_id, name=name) print(result) +@task +def remove_task(c, goal_id, name): + result = Data().add_task(goal_id=goal_id, name=name) + print(result) + + @task def list(c):