From 59f9caeadc42366c2d27392fc195fd626181dc8b Mon Sep 17 00:00:00 2001 From: Shauna Date: Sat, 18 Oct 2014 00:24:25 -0400 Subject: [PATCH] Fix conditional error in message_response Actor needs to be placed in a list in order to match known_nicks, which is a list of lists. Without that, the conditional was never matching people who joined the channel to known_nicks, which meant everyone was getting greeted. Having known_nicks be a list of lists is kind of ugly, and would be nice to change, but for now this is a solid fix (hopefully) --- bot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index 523b0d0..ff591bc 100644 --- a/bot.py +++ b/bot.py @@ -128,7 +128,7 @@ def message_response(bot, ircmsg, actor, ircsock): # if someone (other than the bot) joins the channel if ircmsg.find("JOIN " + channel) != -1 and actor != botnick: - if actor.replace("_", "") not in bot.known_nicks and (i.nick for i in bot.newcomers): # And they're new + if [actor.replace("_", "")] not in bot.known_nicks + [i.nick for i in bot.newcomers]: # And they're new NewComer(actor, bot) # if someone changes their nick while still in newcomers update that nick @@ -215,11 +215,11 @@ def main(): join_irc(ircsock) WelcomeBot = Bot() while 1: # Loop forever - ready_to_read, b, c = select.select([ircsock],[],[], 1) # ignore b&c, doesn't allow keywords + ready_to_read, b, c = select.select([ircsock],[],[], 1) # b&c are ignored here + process_newcomers(WelcomeBot, [i for i in WelcomeBot.newcomers if i.around_for() > WelcomeBot.wait_time],ircsock) if ready_to_read: - ircmsg = msg_handler(ircsock) - process_newcomers(WelcomeBot, [i for i in WelcomeBot.newcomers if i.around_for() > WelcomeBot.wait_time],ircsock) - ircmsg, actor = parse_messages(ircmsg) # parse the next msg in the queue + ircmsg = msg_handler(ircsock) # gets message from ircsock + ircmsg, actor = parse_messages(ircmsg) # parses it or returns None if ircmsg is not None: # If we were able to parse it message_response(WelcomeBot, ircmsg, actor, ircsock) # Respond to the parsed message