From 472b73cf65b6ef298660085fb6fe49e29b5e9f2d Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 15 Oct 2017 02:16:18 -0700 Subject: [PATCH] classes.Channel: clarify the intended behaviour of sort_prefixes() and get_prefix_modes() --- classes.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes.py b/classes.py index baf10e9..da44589 100644 --- a/classes.py +++ b/classes.py @@ -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