updates to notes

This commit is contained in:
Zodiac 2025-02-18 19:14:09 -08:00
parent fcd8b4de17
commit 21c37d46c7

View File

@ -168,40 +168,24 @@ class NoteTaking:
self.User = Query() self.User = Query()
self.log = logging.getLogger(__name__) self.log = logging.getLogger(__name__)
@command(aliases=['notes'], public=True, options_first=False, use_shlex=True)
@command(aliases=['notes'], public=True)
async def note(self, mask, target, args): async def note(self, mask, target, args):
""" """
Unified note command. %%note
%%note today [<content>...] %%note today [<content>...]
%%note daily [--date <date>] [<content>...] %%note daily [<content>...] [--date=<date>]
%%note general <title> [--tags <tags>] [<content>...] %%note general <title> [<content>...] [--tags <tags>]
%%note list [<type>] %%note list <type>
%%note search <type> <keyword> %%note search <type> <keyword>
%%note summary %%note summary
Options:
--date <date> Date in YYYY-MM-DD format.
--tags <tags> Tags for a general note.
<type> Either 'daily' or 'general'.
<title> Title for a general note.
<content> Content to update the note.
<keyword> Keyword to search in notes.
""" """
# If no subcommand is provided, show the help message.
if not any(args.get(key) for key in ('today', 'daily', 'general', 'list', 'search', 'summary')):
self._show_help(target)
return
try: try:
if not args: if args.get('today'):
# Display the help message if no arguments are provided
help_msg = ircstyle.style("Usage: !note <subcommand> [options]\n", fg="red", bold=True)
help_msg += "Subcommands:\n"
help_msg += ircstyle.style("today", fg="yellow") + " - View or update today's daily note.\n"
help_msg += ircstyle.style("daily [--date <date>]", fg="yellow") + " - View or update a daily note for a specific date (default is today).\n"
help_msg += ircstyle.style("general <title> [--tags <tags>]", fg="yellow") + " - View or update a general note with the given title. Optionally, specify tags.\n"
help_msg += ircstyle.style("list [daily|general]", fg="yellow") + " - List all notes of a specific type (either 'daily' or 'general').\n"
help_msg += ircstyle.style("search <type> <keyword>", fg="yellow") + " - Search for a keyword in notes of a specific type.\n"
help_msg += ircstyle.style("summary", fg="yellow") + " - Display a summary of note counts.\n"
self.bot.privmsg(target, help_msg)
elif args.get('today'):
await self._note_today(mask, target, args) await self._note_today(mask, target, args)
elif args.get('daily'): elif args.get('daily'):
await self._note_daily(mask, target, args) await self._note_daily(mask, target, args)
@ -213,9 +197,6 @@ class NoteTaking:
await self._note_search(target, args) await self._note_search(target, args)
elif args.get('summary'): elif args.get('summary'):
await self._note_summary(target) await self._note_summary(target)
else:
help_msg = ircstyle.style("Invalid subcommand! Use !note for a list of available commands.\n", fg="red", bold=True)
self.bot.privmsg(target, help_msg)
except Exception as e: except Exception as e:
self.bot.log.error(f"Error processing note command: {e}", exc_info=True) self.bot.log.error(f"Error processing note command: {e}", exc_info=True)
self.bot.privmsg( self.bot.privmsg(
@ -223,6 +204,21 @@ class NoteTaking:
ircstyle.style(f"❌ Error processing command: {e}", fg="red", bold=True) ircstyle.style(f"❌ Error processing command: {e}", fg="red", bold=True)
) )
def _show_help(self, target):
help_lines = [
ircstyle.style("Usage: !note <subcommand> [options]", fg="red", bold=True),
"Subcommands:",
f"{ircstyle.style(' today', fg='yellow')} - View or update today's daily note.",
f"{ircstyle.style(' daily [--date <date>]', fg='yellow')} - View or update a daily note for a specific date (default is today).",
f"{ircstyle.style(' general <title> [--tags <tags>]', fg='yellow')} - View or update a general note with the given title. Optionally, specify tags.",
f"{ircstyle.style(' list [daily|general]', fg='yellow')} - List all notes of a specific type.",
f"{ircstyle.style(' search <type> <keyword>', fg='yellow')} - Search for a keyword in notes of a specific type.",
f"{ircstyle.style(' summary', fg='yellow')} - Display a summary of note counts.",
]
for line in help_lines:
self.bot.privmsg(target, line)
async def _note_today(self, mask, target, args): async def _note_today(self, mask, target, args):
""" """
Handle the 'today' subcommand for daily notes. Handle the 'today' subcommand for daily notes.
@ -289,6 +285,7 @@ class NoteTaking:
return return
content_list = args.get('<content>') content_list = args.get('<content>')
try: try:
note = self._get_daily_note(day) note = self._get_daily_note(day)
if content_list: if content_list: