From 19ad30587cb37a85cc0b6d7dc331877e2356aabd Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 4 Sep 2019 20:48:50 +0200 Subject: [PATCH] Aggiunta sintassi di @ProtoxiDe22 per mm e reminder --- royalnet/commands/royalgames/mm.py | 6 +++++- royalnet/commands/royalgames/reminder.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/royalnet/commands/royalgames/mm.py b/royalnet/commands/royalgames/mm.py index 0621e628..49cd1e14 100644 --- a/royalnet/commands/royalgames/mm.py +++ b/royalnet/commands/royalgames/mm.py @@ -71,7 +71,11 @@ class MmCommand(Command): raise UnsupportedError("mm is supported only on Telegram") client: telegram.Bot = self.interface.bot.client creator = await data.get_author(error_if_none=True) - timestring, title, description = args.match(r"\[\s*([^]]+)\s*]\s*([^\n]+)\s*\n?\s*(.+)?\s*") + + try: + timestring, title, description = args.match(r"\[\s*([^]]+)\s*]\s*([^\n]+)\s*\n?\s*(.+)?\s*") + except InvalidInputError: + timestring, title, description = args.match(r"\s*(.+?)\s*\n\s*([^\n]+)\s*\n?\s*(.+)?\s*") try: dt: typing.Optional[datetime.datetime] = dateparser.parse(timestring) diff --git a/royalnet/commands/royalgames/reminder.py b/royalnet/commands/royalgames/reminder.py index bbfe850b..df3c156d 100644 --- a/royalnet/commands/royalgames/reminder.py +++ b/royalnet/commands/royalgames/reminder.py @@ -53,7 +53,11 @@ class ReminderCommand(Command): await channel.send(discord_escape(f"❗️ {reminder.message}")) async def run(self, args: CommandArgs, data: CommandData) -> None: - date_str, reminder_text = args.match(r"\[ *(.+?) *] *(.+?) *$") + try: + date_str, reminder_text = args.match(r"\[\s*([^]]+)\s*]\s*([^\n]+)\s*") + except InvalidInputError: + date_str, reminder_text = args.match(r"\s*(.+?)\s*\n\s*([^\n]+)\s*") + try: date: typing.Optional[datetime.datetime] = dateparser.parse(date_str) except OverflowError: