Pre-compile arkhamdb URL regex
This commit is contained in:
parent
4ba198c00e
commit
add2e0362a
@ -31,12 +31,14 @@ class ArkhamDBUpdater(discord.Client):
|
||||
|
||||
async def gather_deck_ids(self, channel: discord.TextChannel) -> dict[int, str]:
|
||||
deck_ids: dict[int, str] = {}
|
||||
url_regex = re.compile(
|
||||
r'(?P<prefix>.*)' + self.arkhamdb_client.origin + r'/deck/view/(?P<deck_id>\d+)')
|
||||
async for message in channel.history(limit=200, oldest_first=True):
|
||||
# ignore the bot's messages
|
||||
if message.author.id == self.user.id:
|
||||
continue
|
||||
|
||||
matches = re.finditer(r'(?P<prefix>.*)' + self.arkhamdb_client.origin + r'/deck/view/(?P<deck_id>\d+)', message.content)
|
||||
matches = url_regex.finditer(message.content)
|
||||
for match in matches:
|
||||
deck_ids[int(match.group('deck_id'))] = match.group('prefix')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user