From 8d1ef828f02df0f62b81fc6560f16e0408c92a8f Mon Sep 17 00:00:00 2001 From: Ave Date: Tue, 13 Oct 2020 17:32:55 +0300 Subject: [PATCH] yubicootp: Properly fetch mid-message OTPs, allow 1+ OTPs per msg --- cogs/yubicootp.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cogs/yubicootp.py b/cogs/yubicootp.py index ca0d7b7..22608d7 100644 --- a/cogs/yubicootp.py +++ b/cogs/yubicootp.py @@ -8,7 +8,7 @@ import asyncio class YubicoOTP(Cog): def __init__(self, bot): self.bot = bot - self.otp_re = re.compile("(cc|vv)[cbdefghijklnrtuv]{42}$") + self.otp_re = re.compile("((cc|vv)[cbdefghijklnrtuv]{42})$") self.api_servers = [ "https://api.yubico.com", "https://api2.yubico.com", @@ -93,9 +93,9 @@ class YubicoOTP(Cog): @Cog.listener() async def on_message(self, message): await self.bot.wait_until_ready() - strin = self.otp_re.match(message.content.strip()) - if strin: - otp = strin.string + otps = self.otp_re.findall(message.content.strip()) + for otp_entry in otps: + otp = otp_entry[0] # Validate OTP validation_result = await self.validate_yubico_otp(otp) if validation_result is not True: @@ -105,7 +105,7 @@ class YubicoOTP(Cog): serial = self.get_serial(otp) serial_str = f" (serial: `{serial}`)" if serial else "" - # If the message content is _just_ the OTP code, delete it too + # If the message content is _just_ the OTP code, delete it toos if message.content.strip() == otp: await message.delete()