kike: implement the ISON command
This commit is contained in:
parent
cf700a5a86
commit
ad7d17d2d8
23
src/kike.c
23
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++)
|
||||
|
Loading…
Reference in New Issue
Block a user