From 6e2555794681155469349616352fdf1395995b14 Mon Sep 17 00:00:00 2001 From: Shauna Date: Thu, 9 Apr 2015 12:14:07 -0400 Subject: [PATCH] Attempt to fix response to pong --- bot.py | 7 ++++--- test_bot.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 1dd3823..e34c571 100644 --- a/bot.py +++ b/bot.py @@ -174,7 +174,7 @@ def message_response(bot, ircmsg, actor, ircsock, channel, greeters): # If the server pings us then we've got to respond! if ircmsg.find("PING :") != -1: - pong(ircsock) + pong(ircsock, ircmsg) ############################################################# @@ -219,8 +219,9 @@ def wait_time_change(actor, ircmsg, ircsock, channel, channel_greeters): "assistance.\n".format(channel, actor, greeter_string(channel_greeters))) # Responds to server Pings. -def pong(ircsock): - ircsock.send("PONG :pingis\n") +def pong(ircsock, ircmsg): + response = "PONG :" + ircmsg.split("PING :")[1] + "\n" + ircsock.send(response) ########################## diff --git a/test_bot.py b/test_bot.py index 682a709..5dc72c6 100644 --- a/test_bot.py +++ b/test_bot.py @@ -194,7 +194,7 @@ class TestMessageResponse(unittest.TestCase): def test_pong(self): botcode.message_response(self.bot,"PING :","Shauna",ircsock=self.ircsock, channel=settings.channel, greeters=settings.channel_greeters) # Replace this with actual ping message - self.assertEqual(self.ircsock.sent_message(),"PONG :pingis\n") + self.assertEqual(self.ircsock.sent_message(),"PONG :\n") def test_bad_pong(self): botcode.message_response(self.bot,"PING!!! :","Shauna",ircsock=self.ircsock, channel=settings.channel, greeters=settings.channel_greeters) # Replace this with actual ping message