fix(bot): normalize mention case for command handling

Ensure that the bot commands are recognized regardless of the letter casing of the mention. This improves command compatibility and user experience by allowing flexibility in how the bot is invoked. Prior to this change, commands were case-sensitive, potentially leading to inconsistencies in command recognition.
This commit is contained in:
Kumi 2024-11-12 21:31:25 +01:00
parent 9c514cd9cd
commit f491c8be41
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -64,7 +64,7 @@ class ApplicationBot:
body = event.body if hasattr(event, "body") else None body = event.body if hasattr(event, "body") else None
if body: if body:
mention = body.split()[0] mention = body.split()[0].lower()
if mention == "!applicationbot" or mention in self.username: if mention == "!applicationbot" or mention in self.username:
return await self.handle_command(room, sender, body.split(" ", 1)[1]) return await self.handle_command(room, sender, body.split(" ", 1)[1])