3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

classes: implement IrcChannel.isOp, isVoice, getPrefixmodes, etc

Ref #168.
This commit is contained in:
James Lu 2016-03-19 17:32:32 -07:00
parent 8135f3a735
commit ed333a6d1b

View File

@ -596,6 +596,40 @@ class IrcChannel():
"""Returns a deep copy of the channel object."""
return deepcopy(self)
def isVoice(self, uid):
"""Returns whether the given user is voice in the channel."""
return uid in self.prefixmodes['voice']
def isHalfop(self, uid):
"""Returns whether the given user is halfop in the channel."""
return uid in self.prefixmodes['halfop']
def isOp(self, uid):
"""Returns whether the given user is op in the channel."""
return uid in self.prefixmodes['op']
def isAdmin(self, uid):
"""Returns whether the given user is admin (&) in the channel."""
return uid in self.prefixmodes['admin']
def isOwner(self, uid):
"""Returns whether the given user is owner (~) in the channel."""
return uid in self.prefixmodes['owner']
def getPrefixModes(self, uid):
"""Returns a list of all named prefix modes the given user has in the channel."""
if uid not in self.users:
return KeyError("User %s does not exist or is not in the channel" % uid)
result = []
for mode, modelist in self.prefixmodes.items():
if uid in modelist:
result.append(mode)
return result
class Protocol():
"""Base Protocol module class for PyLink."""
def __init__(self, irc):