summaryrefslogtreecommitdiff
path: root/miniircd
diff options
context:
space:
mode:
authorBraxton Plaxco <bplaxco@lupnix.org>2017-05-12 08:06:43 -0400
committerJoel Rosdahl <joel@rosdahl.net>2017-05-22 21:42:42 +0200
commita0f9244fca067807533617341daccdf7b539a4c4 (patch)
tree64d764fd18a11ff7379e4c5e70b45b8e0c11ca35 /miniircd
parent78b9b19137a2f9b6bea1a8abb6f569f94b214bc7 (diff)
downloadminiircd-a0f9244fca067807533617341daccdf7b539a4c4.tar.gz
miniircd-a0f9244fca067807533617341daccdf7b539a4c4.zip
Add basic names support
~ B'ezrat Hashem ~
Diffstat (limited to 'miniircd')
-rwxr-xr-xminiircd23
1 files changed, 23 insertions, 0 deletions
diff --git a/miniircd b/miniircd
index f7d7315..98c52ac 100755
--- a/miniircd
+++ b/miniircd
@@ -364,6 +364,28 @@ class Client(object):
def motd_handler():
self.send_motd()
+ def names_handler():
+ channelname = irc_lower(arguments[0])
+ channel = self.channels[channelname]
+ names_prefix = "353 %s = %s :" % (self.nickname, channelname)
+ names = ""
+ # Max length: reply prefix ":server_name(space)" plus CRLF in
+ # the end.
+ names_max_len = 512 - (len(self.server.name) + 2 + 2)
+ for name in sorted(x.nickname for x in channel.members):
+ if not names:
+ names = names_prefix + name
+ # Using >= to include the space between "names" and "name".
+ elif len(names) + len(name) >= names_max_len:
+ self.reply(names)
+ names = names_prefix + name
+ else:
+ names += " " + name
+ if names:
+ self.reply(names)
+ self.reply("366 %s %s :End of NAMES list"
+ % (self.nickname, channelname))
+
def nick_handler():
if len(arguments) < 1:
self.reply("431 :No nickname given")
@@ -530,6 +552,7 @@ class Client(object):
"LUSERS": lusers_handler,
"MODE": mode_handler,
"MOTD": motd_handler,
+ "NAMES": names_handler,
"NICK": nick_handler,
"NOTICE": notice_and_privmsg_handler,
"PART": part_handler,