Skip to content

Commit

Permalink
[Captcha] fix message check
Browse files Browse the repository at this point in the history
  • Loading branch information
japandotorg committed Oct 25, 2023
1 parent 6a07c67 commit 38e500d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions captcha/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ async def on_member_join(self, member: discord.Member) -> None:
self._verification_phase[member.id] = 0
self._user_tries[member.id] = []

message: str = "".join(random.choice(string.ascii_uppercase) for _ in range(6))
message_string: str = "".join(random.choice(string.ascii_uppercase) for _ in range(6))

captcha: CaptchaObj = CaptchaObj(self, width=300, height=100)
captcha.generate(message)
captcha.write(message, f"{str(self.data_path)}/{member.id}.png")
captcha.generate(message_string)
captcha.write(message_string, f"{str(self.data_path)}/{member.id}.png")

captcha_file: discord.File = discord.File(f"{str(self.data_path)}/{member.id}.png")

Expand Down Expand Up @@ -201,18 +201,16 @@ async def on_member_join(self, member: discord.Member) -> None:

def check(message: discord.Message) -> bool:
return (
message.content.upper() == message
message.content.upper() == message_string
and message.author.id == member.id
and message.channel == channel
and message.channel.id == channel.id
)

await self.bot.wait_for(
"message",
check=check,
timeout=timeout,
)

del self._verification_phase[member.id]
except asyncio.TimeoutError:
await member.kick(
reason=f"{member.id} failed to solve captcha verification in time.",
Expand All @@ -221,6 +219,8 @@ def check(message: discord.Message) -> bool:
del self._verification_phase[member.id]
del self._user_tries[member.id]
else:
del self._verification_phase[member.id]

message_after_captcha: str = await self.config.guild(
member.guild
).message_after_captcha()
Expand Down

0 comments on commit 38e500d

Please sign in to comment.