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:
parent
602b2f1176
commit
59f9caeadc
10
bot.py
10
bot.py
|
@ -128,7 +128,7 @@ def message_response(bot, ircmsg, actor, ircsock):
|
||||||
|
|
||||||
# if someone (other than the bot) joins the channel
|
# if someone (other than the bot) joins the channel
|
||||||
if ircmsg.find("JOIN " + channel) != -1 and actor != botnick:
|
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)
|
NewComer(actor, bot)
|
||||||
|
|
||||||
# if someone changes their nick while still in newcomers update that nick
|
# if someone changes their nick while still in newcomers update that nick
|
||||||
|
@ -215,11 +215,11 @@ def main():
|
||||||
join_irc(ircsock)
|
join_irc(ircsock)
|
||||||
WelcomeBot = Bot()
|
WelcomeBot = Bot()
|
||||||
while 1: # Loop forever
|
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
|
||||||
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)
|
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
|
if ircmsg is not None: # If we were able to parse it
|
||||||
message_response(WelcomeBot, ircmsg, actor, ircsock) # Respond to the parsed message
|
message_response(WelcomeBot, ircmsg, actor, ircsock) # Respond to the parsed message
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user