improved the leaderboard regex

This commit is contained in:
2021-08-13 19:42:12 -05:00
parent 108a51b9fe
commit 0b8ecb00b2

View File

@@ -25,9 +25,14 @@ class RoboPage(discord.Client):
attrs = filter(lambda n: n.endswith('Joke') and not n.startswith('Joke'), dir(jokes)) attrs = filter(lambda n: n.endswith('Joke') and not n.startswith('Joke'), dir(jokes))
attrs = map(lambda n: getattr(jokes, n)(), attrs) attrs = map(lambda n: getattr(jokes, n)(), attrs)
self.jokes = list(attrs) self.jokes = list(attrs)
self.most_regex = re.compile("^who is the most (?P<emoji>\w+)(?: in the past (?P<days>\d+) days)?\??$", self.most_regex = re.compile(
re.IGNORECASE) "^who is the most (?P<emoji>\w+)(?: in the past (?P<days>\d+) days)?\??$",
self.leaderboard_regex = re.compile('^most (?P<emoji>\w+) leaderboard$', re.IGNORECASE) re.IGNORECASE
)
self.leaderboard_regex = re.compile(
'^most (?P<emoji>\w+)(?=(?:.+)?leaderboard)(?:.+(?P<days>\d+) days)?',
re.IGNORECASE
)
with Path('gifs.json').open('r') as file: with Path('gifs.json').open('r') as file:
self.gifs = json.load(file) self.gifs = json.load(file)