From aeb53a14e3288ac712f45077ed5facc1fb513f2a Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 20 Jun 2015 20:58:25 -0700 Subject: [PATCH] Make IrcUser.modes a set --- classes.py | 2 +- protocols/inspircd.py | 2 +- utils.py | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/classes.py b/classes.py index 2c0bd31..2831cb6 100644 --- a/classes.py +++ b/classes.py @@ -1,7 +1,7 @@ class IrcUser(): def __init__(self, nick, ts, uid, ident='null', host='null', realname='PyLink dummy client', realhost='null', - ip='0.0.0.0', modes=[]): + ip='0.0.0.0', modes=set()): self.nick = nick self.ts = ts self.uid = uid diff --git a/protocols/inspircd.py b/protocols/inspircd.py index c7fe732..292641b 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -127,7 +127,7 @@ def connect(irc): # :751 UID 751AAAAAA 1220196319 Brain brainwave.brainbox.cc # netadmin.chatspike.net brain 192.168.1.10 1220196324 +Siosw # +ACKNOQcdfgklnoqtx :Craig Edwards - irc.pseudoclient = spawnClient(irc, 'PyLink', 'pylink', host, modes=["+o"]) + irc.pseudoclient = spawnClient(irc, 'PyLink', 'pylink', host, modes=set(["+o"])) f(':%s ENDBURST' % (irc.sid)) for chan in irc.serverdata['channels']: joinClient(irc, irc.pseudoclient.uid, chan) diff --git a/utils.py b/utils.py index 0be5670..7841624 100644 --- a/utils.py +++ b/utils.py @@ -79,13 +79,10 @@ def applyModes(modelist, changedmodes): for mode in changedmodes: if mode[0] == '+': # We're adding a mode - modelist.append(mode) + modelist.add(mode) else: # We're removing a mode - try: - modelist.remove(mode) - except ValueError: - print('Attempted to remove modes %r not in %s\'s modes' % (mode, numeric)) + modelist.discard(mode) return modelist def joinModes(modes):