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)
This commit is contained in:
Shauna 2014-10-18 00:24:25 -04:00
parent 602b2f1176
commit 59f9caeadc

10
bot.py
View File

@ -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
if ready_to_read:
ircmsg = msg_handler(ircsock)
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)
ircmsg, actor = parse_messages(ircmsg) # parse the next msg in the queue
if ready_to_read:
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