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

classes.Channel: clarify the intended behaviour of sort_prefixes() and get_prefix_modes()

This commit is contained in:
James Lu 2017-10-15 02:16:18 -07:00
parent 4935ef521e
commit 472b73cf65

View File

@ -1719,8 +1719,10 @@ class Channel(structures.DeprecatedAttributesObject, structures.CamelCaseToSnake
@staticmethod
def sort_prefixes(key):
"""
Implements a sorted()-compatible sorter for prefix modes, giving each one a
numeric value.
Returns a numeric value for a named prefix mode: higher ranks have lower values
(sorted first), and lower ranks have higher values (sorted last).
This function essentially implements a sorted() key function for named prefix modes.
"""
values = {'owner': 0, 'admin': 100, 'op': 200, 'halfop': 300, 'voice': 500}
@ -1728,7 +1730,9 @@ class Channel(structures.DeprecatedAttributesObject, structures.CamelCaseToSnake
return values.get(key, 1000)
def get_prefix_modes(self, uid, prefixmodes=None):
"""Returns a list of all named prefix modes the given user has in the channel.
"""
Returns a list of all named prefix modes the user has in the channel, in
increasing order from voice to owner.
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