From fcbe7af1e2ac2abb71251a51f5384d22cad9a87a Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 11 Sep 2022 17:34:41 -0400 Subject: Generate /ops from cache --- command.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'command.c') diff --git a/command.c b/command.c index 3acbe76..4fb58da 100644 --- a/command.c +++ b/command.c @@ -219,8 +219,31 @@ static void commandNames(uint id, char *params) { static void commandOps(uint id, char *params) { (void)params; - ircFormat("WHO %s\r\n", idNames[id]); - replies[ReplyWho]++; + char buf[1024]; + char *ptr = buf, *end = &buf[sizeof(buf)]; + ptr = seprintf( + ptr, end, "The council of \3%02d%s\3 are ", + idColors[id], idNames[id] + ); + bool first = true; + struct Cursor curs = {0}; + for (const char *nick; (nick = cacheNextKey(&curs, id));) { + char prefix = bitPrefix(curs.entry->prefixBits); + if (!prefix || prefix == '+') continue; + ptr = seprintf( + ptr, end, "%s\3%02d%c%s\3", + (first ? "" : ", "), curs.entry->color, prefix, nick + ); + first = false; + } + if (first) { + uiFormat( + id, Warm, NULL, "\3%02d%s\3 is a lawless wasteland", + idColors[id], idNames[id] + ); + } else { + uiWrite(id, Warm, NULL, buf); + } } static void commandInvite(uint id, char *params) { -- cgit 1.4.1