yubicootp: Properly fetch mid-message OTPs, allow 1+ OTPs per msg
This commit is contained in:
parent
6f30585c96
commit
8d1ef828f0
1 changed files with 5 additions and 5 deletions
|
@ -8,7 +8,7 @@ import asyncio
|
||||||
class YubicoOTP(Cog):
|
class YubicoOTP(Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = 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 = [
|
self.api_servers = [
|
||||||
"https://api.yubico.com",
|
"https://api.yubico.com",
|
||||||
"https://api2.yubico.com",
|
"https://api2.yubico.com",
|
||||||
|
@ -93,9 +93,9 @@ class YubicoOTP(Cog):
|
||||||
@Cog.listener()
|
@Cog.listener()
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
strin = self.otp_re.match(message.content.strip())
|
otps = self.otp_re.findall(message.content.strip())
|
||||||
if strin:
|
for otp_entry in otps:
|
||||||
otp = strin.string
|
otp = otp_entry[0]
|
||||||
# Validate OTP
|
# Validate OTP
|
||||||
validation_result = await self.validate_yubico_otp(otp)
|
validation_result = await self.validate_yubico_otp(otp)
|
||||||
if validation_result is not True:
|
if validation_result is not True:
|
||||||
|
@ -105,7 +105,7 @@ class YubicoOTP(Cog):
|
||||||
serial = self.get_serial(otp)
|
serial = self.get_serial(otp)
|
||||||
serial_str = f" (serial: `{serial}`)" if serial else ""
|
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:
|
if message.content.strip() == otp:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue