From 1f992fe9817de7d597ca4b1a4f1dc142b2c1dc86 Mon Sep 17 00:00:00 2001 From: josiah Date: Sat, 14 Aug 2021 12:14:49 -0500 Subject: [PATCH] Allow basic integration between orgmode and the matrix. - Doesn't add meta data yet. - Isn't very smart, will assume you did a bunch of stuff right instead - of verifying itself. --- molly/bot_commands.py | 12 ++++++++++++ molly/config.py | 3 +++ 2 files changed, 15 insertions(+) diff --git a/molly/bot_commands.py b/molly/bot_commands.py index 4aa76ae..21e4996 100644 --- a/molly/bot_commands.py +++ b/molly/bot_commands.py @@ -46,6 +46,8 @@ class Command: await self._react() elif self.command.startswith("help"): await self._show_help() + elif self.command.startswith("scribe"): + await self._new_org_todo() else: await self._unknown_command() @@ -87,6 +89,16 @@ class Command: text = "Unknown help topic!" await send_text_to_room(self.client, self.room.room_id, text) + async def _new_org_todo(self): + """Given a plaintext string, return org-formatted todo line.""" + formatted_string = " ".join(self.args) + new_string = f"* {formatted_string} \n" + await send_text_to_room(self.client, self.room.room_id, f"creating new todo with {new_string}") + print(dir(self.config)) + with open(self.config.orgmode_refile_path, "a") as orgfile: + orgfile.write(new_string) + # return new_string + async def _unknown_command(self): await send_text_to_room( self.client, diff --git a/molly/config.py b/molly/config.py index 1f8e2f4..8f8cb24 100644 --- a/molly/config.py +++ b/molly/config.py @@ -70,6 +70,9 @@ class Config: f"storage.store_path '{self.store_path}' is not a directory" ) + # Orgmode setup + self.orgmode_refile_path = self._get_cfg(["orgmode", "refile"], required=True) + # Database setup database_path = self._get_cfg(["storage", "database"], required=True)