aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-08-05 23:10:59 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-08-05 23:10:59 +0200
commitad7d17d2d8bda0778c953727e893612ac7a3a3c2 (patch)
tree47bfd6f11d9bd9e87b36032ace21ab314864cf59 /src
parentcf700a5a866d1c3990e63a89c2d2200b37072cfb (diff)
downloadxK-ad7d17d2d8bda0778c953727e893612ac7a3a3c2.tar.gz
xK-ad7d17d2d8bda0778c953727e893612ac7a3a3c2.tar.xz
xK-ad7d17d2d8bda0778c953727e893612ac7a3a3c2.zip
kike: implement the ISON command
Diffstat (limited to 'src')
-rw-r--r--src/kike.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/kike.c b/src/kike.c
index 020e8c3..82b3385 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -808,6 +808,7 @@ enum
IRC_RPL_AWAY = 301,
IRC_RPL_USERHOST = 302,
+ IRC_RPL_ISON = 303,
IRC_RPL_UNAWAY = 305,
IRC_RPL_NOWAWAY = 306,
IRC_RPL_ENDOFWHO = 315,
@@ -876,6 +877,7 @@ static const char *g_default_replies[] =
[IRC_RPL_AWAY] = "%s :%s",
[IRC_RPL_USERHOST] = ":%s",
+ [IRC_RPL_ISON] = ":%s",
[IRC_RPL_UNAWAY] = ":You are no longer marked as being away",
[IRC_RPL_NOWAWAY] = ":You have been marked as being away",
[IRC_RPL_ENDOFWHO] = "%s :End of WHO list",
@@ -1837,6 +1839,26 @@ irc_handle_away (const struct irc_message *msg, struct client *c)
}
}
+static void
+irc_handle_ison (const struct irc_message *msg, struct client *c)
+{
+ if (msg->params.len < 1)
+ RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
+
+ struct str result;
+ str_init (&result);
+
+ const char *nick;
+ if (str_map_find (&c->ctx->users, (nick = msg->params.vector[0])))
+ str_append (&result, nick);
+ for (size_t i = 1; i < msg->params.len; i++)
+ if (str_map_find (&c->ctx->users, (nick = msg->params.vector[i])))
+ str_append_printf (&result, " %s", nick);
+
+ irc_send_reply (c, IRC_RPL_ISON, result.str);
+ str_free (&result);
+}
+
// -----------------------------------------------------------------------------
struct irc_command
@@ -1879,6 +1901,7 @@ irc_register_handlers (struct server_context *ctx)
{ "LIST", true, irc_handle_list },
{ "NAMES", true, irc_handle_names },
{ "WHO", true, irc_handle_who },
+ { "ISON", true, irc_handle_ison },
};
for (size_t i = 0; i < N_ELEMENTS (message_handlers); i++)