diff --git a/src/werewolf_bot.py b/src/werewolf_bot.py index 7ee894e..0f398a3 100644 --- a/src/werewolf_bot.py +++ b/src/werewolf_bot.py @@ -159,6 +159,6 @@ async def logout(ctx): @developer async def debug(ctx): print("DEBUG") - print(ctx.message.author.id) + print(ctx.message.content) bot.run(TOKEN) diff --git a/src/werewolf_roles.py b/src/werewolf_roles.py index 0c5b213..6c7ef22 100644 --- a/src/werewolf_roles.py +++ b/src/werewolf_roles.py @@ -1,4 +1,5 @@ import functools +from fuzzywuzzy import fuzz from werewolf_players import No_player @@ -20,10 +21,7 @@ class Role: @staticmethod def match(message): - for role_class in Role.__subclasses__(): - if message.casefold() == role_class.name(): - return role_class - raise ValueError(f"Invalid role: {message}") + return max(Role.__subclasses__(), key=lambda role_class: fuzz.ratio(message, role_class.name())) @staticmethod def no_player(func): @@ -160,7 +158,7 @@ class Drunk(Role): class Insomniac(Role): @Role.no_player async def send_info(self): - await self.player.send_info(f"You are now: {self.player.day_role}") + await self.player.send_info(f"You are: {self.player.day_role}") class Villager(Role):