1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Aggiunta sintassi di @ProtoxiDe22 per mm e reminder

This commit is contained in:
Steffo 2019-09-04 20:48:50 +02:00
parent d53329851a
commit 19ad30587c
2 changed files with 10 additions and 2 deletions

View file

@ -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)

View file

@ -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: