From 33e3b0ce1bf0cf3126393466f198dcddee802b65 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 30 May 2021 12:35:16 -0400 Subject: [PATCH] fix #1669 Sort snomasks for display rather than displaying them in hash order --- irc/sno/utils.go | 5 +++++ irc/snomanager.go | 1 + 2 files changed, 6 insertions(+) diff --git a/irc/sno/utils.go b/irc/sno/utils.go index 572ab394..72f55f13 100644 --- a/irc/sno/utils.go +++ b/irc/sno/utils.go @@ -4,6 +4,7 @@ package sno import ( + "sort" "strings" ) @@ -34,6 +35,10 @@ func (masks Masks) Contains(mask Mask) bool { return false } +func (masks Masks) Sort() { + sort.Slice(masks, func(i, j int) bool { return masks[i] < masks[j] }) +} + // Evaluate changes to snomasks made with MODE. There are several cases: // adding snomasks with `/mode +s a` or `/mode +s +a`, removing them with `/mode +s -a`, // adding all with `/mode +s *` or `/mode +s +*`, removing all with `/mode +s -*` or `/mode -s` diff --git a/irc/snomanager.go b/irc/snomanager.go index 994934fa..52ff0ec1 100644 --- a/irc/snomanager.go +++ b/irc/snomanager.go @@ -109,6 +109,7 @@ func (m *SnoManager) MasksEnabled(client *Client) (result sno.Masks) { } } } + result.Sort() return }