3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-17 14:01:03 +01:00

classes: Implement IrcChannel.is(Voice|Halfop|Op)Plus (#168)

This commit is contained in:
James Lu 2016-03-19 17:37:38 -07:00
parent ed333a6d1b
commit e8b0018585

View File

@ -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."""