diff --git a/src/run/message_responder.py b/src/run/message_responder.py index 9161169..ce5a276 100644 --- a/src/run/message_responder.py +++ b/src/run/message_responder.py @@ -92,7 +92,7 @@ def clean_up_and_split_message_text(self, message_text): return clean_split - def get_self_mention(self, ): + def get_self_mention(self): return self.client.user.mention async def process_guild_message_text_from_player(self, channel, message): @@ -379,7 +379,7 @@ async def on_ready(self, ): print(f'We have logged in as {self.client.user}') async def on_message(self, message): - if message.author == self.client.user: + if message.author.bot: return await self.expire_challenges() if message.channel.guild is not None: diff --git a/src/test/framework/spoofer_classes.py b/src/test/framework/spoofer_classes.py index 7ba1af9..180c729 100644 --- a/src/test/framework/spoofer_classes.py +++ b/src/test/framework/spoofer_classes.py @@ -15,6 +15,7 @@ def __init__(self, users, guild_channels, new_client): class Client: def __init__(self, user): self.user = user + user.bot = True class Message: def __init__(self, author, channel, content, mentions): @@ -36,6 +37,7 @@ def __init__(self, display_name): self.display_name = display_name self.mention = "<" + str(int(hash(display_name))) + ">" player_mention_map[self.mention] = self + self.bot = False async def send(self, message): await self.channel.send(message) diff --git a/src/test/test_message_responder_statics.py b/src/test/test_message_responder_statics.py index 75fc1fc..426414d 100644 --- a/src/test/test_message_responder_statics.py +++ b/src/test/test_message_responder_statics.py @@ -15,21 +15,31 @@ async def set_up_spoof(): async def responder_test_basic_static(): beckett = spoof.users[0] channel = spoof.guild_channels[0] - message = Message(beckett, channel, spoof.client.user.mention + " static", [spoof.client.user]) #We don't actually spoof mentions correctly... I'll update that later if needed. + message = Message(beckett, channel, spoof.client.user.mention + " static", [spoof.client.user]) await channel.spoof_send(message, responder) expect(len(channel.message_history) >= 2, "A message back was not received.") expect(channel.message_history[1].content.startswith(beckett.mention + ", you"), "Something other than a static occurred. Message: " + channel.message_history[1].content) +@test +async def responder_test_static_from_bot(): + channel = spoof.guild_channels[0] + channel.message_history = [] + beckett = spoof.users[0] + beckett.bot = True #oh no robo beckett + message = Message(beckett, channel, spoof.client.user.mention + " static", [spoof.client.user]) + await channel.spoof_send(message, responder) + expect(len(channel.message_history) == 1, "Robots shouldn't get a response - even if they're Gangrel.") + @test async def responder_test_statistical_bias(): wins = 0 losses = 0 ties = 0 - tries = 0 + beckett = spoof.users[0] + beckett.bot = False #he's cured :) while tries < 1000: tries += 1 - beckett = spoof.users[0] channel = spoof.guild_channels[0] message = Message(beckett, channel, spoof.client.user.mention + " static", [spoof.client.user]) await channel.spoof_send(message, responder) @@ -50,4 +60,5 @@ async def responder_test_statistical_bias(): async def run_tests(): await set_up_spoof() await responder_test_basic_static() + await responder_test_static_from_bot() await responder_test_statistical_bias()