From ce249dfe334cc257797bbebeea08eba0426192af Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 20 Jun 2015 21:06:45 -0700 Subject: [PATCH] uhhh.... let's clear our variables properly --- protocols/inspircd.py | 6 ++++-- utils.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 292641b..92de52c 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -212,7 +212,9 @@ def handle_uid(irc, numeric, command, args): uid, ts, nick, realhost, host, ident, ip = args[0:7] realname = args[-1] irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip) - utils.applyModes(irc.users[uid].modes, utils.parseModes(args[8:9])) + parsedmodes = utils.parseModes(args[8:9]) + print('Applying modes %s for %s' % (parsedmodes, uid)) + irc.users[uid].modes = utils.applyModes(irc.users[uid].modes, parsedmodes) irc.servers[numeric].users.append(uid) def handle_quit(irc, numeric, command, args): @@ -259,7 +261,7 @@ def handle_mode(irc, numeric, command, args): target = args[0] modestrings = args[1:] changedmodes = utils.parseModes(modestrings) - utils.applyModes(irc.users[numeric].modes, changedmodes) + irc.users[numeric].modes = utils.applyModes(irc.users[numeric].modes, changedmodes) def handle_squit(irc, numeric, command, args): # :70M SQUIT 1ML :Server quit by GL!gl@0::1 diff --git a/utils.py b/utils.py index 7841624..205fabb 100644 --- a/utils.py +++ b/utils.py @@ -76,13 +76,19 @@ def parseModes(args): return res def applyModes(modelist, changedmodes): + modelist = modelist.copy() + print('Initial modelist: %s' % modelist) + print('Changedmodes: %r' % changedmodes) for mode in changedmodes: if mode[0] == '+': # We're adding a mode modelist.add(mode) + print('Adding mode %r' % mode) else: # We're removing a mode modelist.discard(mode) + print('Removing mode %r' % mode) + print('Final modelist: %s' % modelist) return modelist def joinModes(modes):