1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Add missing f-string

This commit is contained in:
Steffo 2019-09-08 13:22:52 +02:00
parent a18aa5ef54
commit 2d782c53ec
2 changed files with 6 additions and 5 deletions

View file

@ -38,7 +38,7 @@ class CommandArgs(list):
raise InvalidInputError("Not enough arguments") raise InvalidInputError("Not enough arguments")
return " ".join(self) return " ".join(self)
def match(self, pattern: typing.Union[str, typing.Pattern]) -> typing.Sequence[typing.AnyStr]: def match(self, pattern: typing.Union[str, typing.Pattern], *flags) -> typing.Sequence[typing.AnyStr]:
"""Match the :py:func:`royalnet.utils.commandargs.joined` to a regex pattern. """Match the :py:func:`royalnet.utils.commandargs.joined` to a regex pattern.
Parameters: Parameters:
@ -50,7 +50,7 @@ class CommandArgs(list):
Returns: Returns:
The matched groups, as returned by :py:func:`re.Match.groups`.""" The matched groups, as returned by :py:func:`re.Match.groups`."""
text = self.joined() text = self.joined()
match = re.match(pattern, text) match = re.match(pattern, text, *flags)
if match is None: if match is None:
raise InvalidInputError("Pattern didn't match") raise InvalidInputError("Pattern didn't match")
return match.groups() return match.groups()

View file

@ -3,6 +3,7 @@ import dateparser
import os import os
import telegram import telegram
import asyncio import asyncio
import re
from ..command import Command from ..command import Command
from ..commandargs import CommandArgs from ..commandargs import CommandArgs
from ..commanddata import CommandData from ..commanddata import CommandData
@ -84,7 +85,7 @@ class MmCommand(Command):
if mmresponse.response == "YES": if mmresponse.response == "YES":
text += f"{mmresponse.royal}\n" text += f"{mmresponse.royal}\n"
elif mmresponse.response == "NO": elif mmresponse.response == "NO":
text += "{mmresponse.royal}\n" text += f"{mmresponse.royal}\n"
return text return text
async def _run_mm(self, mmevent: MMEvent) -> None: async def _run_mm(self, mmevent: MMEvent) -> None:
@ -336,9 +337,9 @@ class MmCommand(Command):
client: telegram.Bot = self.interface.bot.client client: telegram.Bot = self.interface.bot.client
creator = await data.get_author(error_if_none=True) creator = await data.get_author(error_if_none=True)
try: try:
timestring, title, description = args.match(r"\[\s*([^]]+)\s*]\s*([^\n]+)\s*\n?\s*(.+)?\s*") timestring, title, description = args.match(r"\[\s*([^]]+)\s*]\s*([^\n]+)\s*\n?\s*(.+)?\s*", re.DOTALL)
except InvalidInputError: except InvalidInputError:
timestring, title, description = args.match(r"\s*(.+?)\s*\n\s*([^\n]+)\s*\n?\s*(.+)?\s*") timestring, title, description = args.match(r"\s*(.+?)\s*\n\s*([^\n]+)\s*\n?\s*(.+)?\s*", re.DOTALL)
try: try:
dt: typing.Optional[datetime.datetime] = dateparser.parse(timestring) dt: typing.Optional[datetime.datetime] = dateparser.parse(timestring)
except OverflowError: except OverflowError: