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)