Browse Source

kike: implement LINKS

Přemysl Janouch 3 years ago
parent
commit
abc0e4f821
2 changed files with 20 additions and 0 deletions
  1. 2
    0
      kike-replies
  2. 18
    0
      kike.c

+ 2
- 0
kike-replies View File

@@ -41,6 +41,8 @@
41 41
 351 IRC_RPL_VERSION "%s.%d %s :%s"
42 42
 352 IRC_RPL_WHOREPLY "%s %s %s %s %s %s :%d %s"
43 43
 353 IRC_RPL_NAMREPLY "%c %s :%s"
44
+364 IRC_RPL_LINKS "%s %s :%d %s"
45
+365 IRC_RPL_ENDOFLINKS "%s :End of LINKS list"
44 46
 366 IRC_RPL_ENDOFNAMES "%s :End of NAMES list"
45 47
 367 IRC_RPL_BANLIST "%s %s"
46 48
 368 IRC_RPL_ENDOFBANLIST "%s :End of channel ban list"

+ 18
- 0
kike.c View File

@@ -2917,6 +2917,23 @@ irc_handle_stats (const struct irc_message *msg, struct client *c)
2917 2917
 	irc_send_reply (c, IRC_RPL_ENDOFSTATS, query);
2918 2918
 }
2919 2919
 
2920
+static void
2921
+irc_handle_links (const struct irc_message *msg, struct client *c)
2922
+{
2923
+	if (msg->params.len > 1 && !irc_is_this_me (c->ctx, msg->params.vector[0]))
2924
+		RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHSERVER, msg->params.vector[0]);
2925
+
2926
+	const char *mask = "*";
2927
+	if (msg->params.len > 0)
2928
+		mask = msg->params.vector[msg->params.len > 1];
2929
+
2930
+	if (!irc_fnmatch (mask, c->ctx->server_name))
2931
+		irc_send_reply (c, IRC_RPL_LINKS, mask,
2932
+			c->ctx->server_name, 0 /* hop count */,
2933
+			str_map_find (&c->ctx->config, "server_info"));
2934
+	irc_send_reply (c, IRC_RPL_ENDOFLINKS, mask);
2935
+}
2936
+
2920 2937
 static void
2921 2938
 irc_handle_kill (const struct irc_message *msg, struct client *c)
2922 2939
 {
@@ -2973,6 +2990,7 @@ irc_register_handlers (struct server_context *ctx)
2973 2990
 		{ "AWAY",     true,  irc_handle_away,     0, 0 },
2974 2991
 		{ "ADMIN",    true,  irc_handle_admin,    0, 0 },
2975 2992
 		{ "STATS",    true,  irc_handle_stats,    0, 0 },
2993
+		{ "LINKS",    true,  irc_handle_links,    0, 0 },
2976 2994
 
2977 2995
 		{ "MODE",     true,  irc_handle_mode,     0, 0 },
2978 2996
 		{ "PRIVMSG",  true,  irc_handle_privmsg,  0, 0 },

Loading…
Cancel
Save