From e8b00185854444faa12e0316b09bfe75731a9b60 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 19 Mar 2016 17:37:38 -0700 Subject: [PATCH] classes: Implement IrcChannel.is(Voice|Halfop|Op)Plus (#168) --- classes.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/classes.py b/classes.py index f9c1530..be79e5d 100644 --- a/classes.py +++ b/classes.py @@ -616,6 +616,25 @@ class IrcChannel(): """Returns whether the given user is owner (~) in the channel.""" return uid in self.prefixmodes['owner'] + def isVoicePlus(self, uid): + """Returns whether the given user is voice or above in the channel.""" + # If the user has any prefix mode, it has to be voice or greater. + return bool(self.getPrefixModes(uid)) + + def isHalfopPlus(self, uid): + """Returns whether the given user is halfop or above in the channel.""" + for mode in ('halfop', 'op', 'admin', 'owner'): + if uid in self.prefixmodes[mode]: + return True + return False + + def isOpPlus(self, uid): + """Returns whether the given user is op or above in the channel.""" + for mode in ('op', 'admin', 'owner'): + if uid in self.prefixmodes[mode]: + return True + return False + def getPrefixModes(self, uid): """Returns a list of all named prefix modes the given user has in the channel."""