From e948db5c7bf051ea780bfc36bc47495787b702ee Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 19 Mar 2016 17:54:18 -0700 Subject: [PATCH] classes: support looking at older versions of prefix modes mappings --- classes.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/classes.py b/classes.py index be79e5d..cc21bd9 100644 --- a/classes.py +++ b/classes.py @@ -635,15 +635,21 @@ class IrcChannel(): return True return False - def getPrefixModes(self, uid): - """Returns a list of all named prefix modes the given user has in the channel.""" + def getPrefixModes(self, uid, prefixmodes=None): + """Returns a list of all named prefix modes the given user has in the channel. + + Optionally, a prefixmodes argument can be given to look at an earlier state of + the channel's prefix modes mapping, e.g. for checking the op status of a mode + setter before their modes are processed and added to the channel state. + """ if uid not in self.users: return KeyError("User %s does not exist or is not in the channel" % uid) result = [] + prefixmodes = prefixmodes or self.prefixmodes - for mode, modelist in self.prefixmodes.items(): + for mode, modelist in prefixmodes.items(): if uid in modelist: result.append(mode)