From c9ce4d150723aea102fef75070b5de533a3e9858 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 31 Jul 2016 21:45:38 -0700 Subject: [PATCH] Irc: make sorting in joinModes() an option, and explicitly enable it in WHOIS output This prevents mode lists from being sorted when they really shouldn't be, such as when relaying mode changes ("+qo nick nick" became +oq nick nick"). (cherry picked from commit 4b27ebbee4f06ba64bdd0c25489051ebe2a7ff8d) --- classes.py | 5 +++-- coremods/handlers.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/classes.py b/classes.py index 51aa88b..a59dfb1 100644 --- a/classes.py +++ b/classes.py @@ -751,7 +751,7 @@ class Irc(): return set(newmodes) @staticmethod - def joinModes(modes): + def joinModes(modes, sort=False): """Takes a list of (mode, arg) tuples in parseModes() format, and joins them into a string. @@ -761,7 +761,8 @@ class Irc(): args = [] # Sort modes alphabetically like a conventional IRCd. - modes = sorted(modes) + if sort: + modes = sorted(modes) for modepair in modes: mode, arg = modepair diff --git a/coremods/handlers.py b/coremods/handlers.py index 73c0a57..3c865c3 100644 --- a/coremods/handlers.py +++ b/coremods/handlers.py @@ -87,7 +87,7 @@ def handle_whois(irc, source, command, args): # Only show this to opers! if sourceisOper: f(378, source, "%s :is connecting from %s@%s %s" % (nick, user.ident, user.realhost, user.ip)) - f(379, source, '%s :is using modes %s' % (nick, irc.joinModes(user.modes))) + f(379, source, '%s :is using modes %s' % (nick, irc.joinModes(user.modes, sort=True))) # 301: used to show away information if present away_text = user.away