diff --git a/Code/irc/banterbot.py b/Code/irc/banterbot.py index 991ef2e..198e185 100755 --- a/Code/irc/banterbot.py +++ b/Code/irc/banterbot.py @@ -43,8 +43,8 @@ parser.add_option("-n", "--nick", dest="nick", default='tildebot', p = inflect.engine() -def ping(): - ircsock.send("PONG :pingis\n") +def ping(pong): + ircsock.send("PONG {}\n".format(pong)) def sendmsg(chan , msg): ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n") @@ -263,8 +263,8 @@ def listen(botnick): ircmsg = ircsock.recv(2048) ircmsg = ircmsg.strip('\n\r') - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) formatted = formatter.format_message(ircmsg) @@ -337,8 +337,8 @@ def listen(botnick): if ircmsg.find(":" + botnick + ":") != -1: mug_off(channel) - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) sys.stdout.flush() time.sleep(1) diff --git a/Code/irc/madlibbot/madlibbot.py b/Code/irc/madlibbot/madlibbot.py index 6a228b3..3e20153 100755 --- a/Code/irc/madlibbot/madlibbot.py +++ b/Code/irc/madlibbot/madlibbot.py @@ -25,7 +25,7 @@ class State: MAX_LINE = 80 # The maximum number of characters in a line MAX_STORIES = 5 # The maximum number of stories a user can pick from THROTTLE_FACTOR = 1 # A factor by which all sleep event durations will be multiplied -# Allow madlbibbot to run multiple simultaneous stories +# Allow madlbibbot to run multiple simultaneous stories state = {} # The current state of the bot stories = {} # The list of stories available to users story = {} # The madlib story currently being worked on @@ -179,8 +179,8 @@ def finish_story(channel): state[channel] = State.idle # System things -def ping(): - ircsock.send("PONG :pingis\n") +def ping(pong): + ircsock.send("PONG {}\n".format(pong)) def sendmsg(chan , msg): ircsock.send("PRIVMSG {} :{}\n".format(chan, msg)) @@ -212,8 +212,8 @@ def listen(botnick): ircmsg = ircsock.recv(2048) ircmsg = ircmsg.strip('\n\r') - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) formatted = msgformatter.format_message(ircmsg) if "" == formatted: diff --git a/Code/irc/quote_bot.py b/Code/irc/quote_bot.py index ca3af8c..8dec7cc 100755 --- a/Code/irc/quote_bot.py +++ b/Code/irc/quote_bot.py @@ -22,11 +22,11 @@ parser.add_option("-n", "--nick", dest="nick", default='quote_bot', (options, args) = parser.parse_args() -def ping(): - ircsock.send("PONG :pingis\n") +def ping(pong): + ircsock.send("PONG {}\n".format(pong)) def sendmsg(chan , msg): - ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n") + ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n") def joinchan(chan): ircsock.send("JOIN "+ chan +"\n") @@ -74,21 +74,21 @@ def say_chatty(channel): for line in chattyOut: if line: ircsock.send("PRIVMSG "+ channel + " :" + line + "\n") - + def listen(): while 1: ircmsg = ircsock.recv(2048) ircmsg = ircmsg.strip('\n\r') - if ircmsg.find("PING :") != -1: - ping() - + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) + formatted = formatter.format_message(ircmsg) if "" == formatted: continue - + print formatted split = formatted.split("\t") @@ -108,8 +108,8 @@ def listen(): if ircmsg.find(":!haiku") != -1: haiku(options.channel) - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) sys.stdout.flush() time.sleep(1) diff --git a/Code/irc/tilde_bot.py b/Code/irc/tilde_bot.py index e449e2b..046711a 100755 --- a/Code/irc/tilde_bot.py +++ b/Code/irc/tilde_bot.py @@ -22,11 +22,11 @@ parser.add_option("-n", "--nick", dest="nick", default='tilde_bot', (options, args) = parser.parse_args() -def ping(): - ircsock.send("PONG :pingis\n") +def ping(pong): + ircsock.send("PONG {}\n".format(pong)) def sendmsg(chan , msg): - ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n") + ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n") def joinchan(chan): ircsock.send("JOIN "+ chan +"\n") @@ -61,14 +61,14 @@ def listen(): ircmsg = ircsock.recv(2048) ircmsg = ircmsg.strip('\n\r') - if ircmsg.find("PING :") != -1: - ping() - + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) + formatted = formatter.format_message(ircmsg) if "" == formatted: continue - + print formatted split = formatted.split("\t") @@ -79,8 +79,8 @@ def listen(): if ircmsg.find(":!tilde") != -1: tilde(options.channel, user, time) - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) sys.stdout.flush() diff --git a/Code/irc/topicbot.py b/Code/irc/topicbot.py index 99dd58f..2f11aa4 100755 --- a/Code/irc/topicbot.py +++ b/Code/irc/topicbot.py @@ -30,8 +30,8 @@ parser.add_option("-n", "--nick", dest="nick", default='topicbot', p = inflect.engine() -def ping(): - ircsock.send("PONG :pingis\n") +def ping(pong): + ircsock.send("PONG {}\n".format(pong)) def sendmsg(chan , msg): ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n") @@ -145,8 +145,8 @@ def listen(): ircmsg = ircsock.recv(2048) ircmsg = ircmsg.strip('\n\r') - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) formatted = formatter.format_message(ircmsg) @@ -187,8 +187,8 @@ def listen(): if ircmsg.find(":!rollcall") != -1: rollcall(channel) - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) sys.stdout.flush() time.sleep(1) diff --git a/Code/irc/wangbot.py b/Code/irc/wangbot.py index 7ec0bfa..a28ab25 100755 --- a/Code/irc/wangbot.py +++ b/Code/irc/wangbot.py @@ -56,8 +56,8 @@ def resetGlobals(): currentScores.clear() -def ping(): - ircsock.send("PONG :pingis\n") +def ping(pong): + ircsock.send("PONG {}\n".format(pong)) def sendmsg(chan , msg): ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n") @@ -220,8 +220,8 @@ def listen(): ircmsg = ircsock.recv(2048) ircmsg = ircmsg.strip('\n\r') - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) formatted = formatter.format_message(ircmsg) @@ -254,8 +254,8 @@ def listen(): if ircmsg.find(":!rollcall") != -1: rollcall(channel) - if ircmsg.find("PING :") != -1: - ping() + if ircmsg[:4] == "PING": + ping(ircmsg.split(" ")[1]) sys.stdout.flush() time.sleep(1)