AmendHub

Download:

jcs

/

wallops

/

amendments

/

69

irc: Implement /who


jcs made amendment 69 2 months ago
--- irc.c Sun Sep 8 16:09:54 2024 +++ irc.c Sun Sep 8 20:47:47 2024 @@ -721,7 +721,10 @@ irc_process_server(struct irc_connection *conn) return true; case 315: /* end of WHO */ - goto unknown; + chatter_printf(conn->chatter, conn, NULL, + "$B***$0$/ %s", + msg.msg); + return true; case 317: /* WHOIS idle */ chatter_printf(conn->chatter, conn, conn->current_whois, @@ -783,7 +786,10 @@ irc_process_server(struct irc_connection *conn) return true; case 352: /* WHO output */ - goto unknown; + chatter_printf(conn->chatter, conn, NULL, + "$B***$0$/ %s %s@%s (%s)", + msg.arg[1], msg.arg[2], msg.arg[3], msg.msg); + return true; case 353: /* NAMES output */ if ((channel = irc_find_channel(conn, msg.arg[2]))) @@ -999,6 +1005,17 @@ irc_process_input(struct irc_connection *conn, struct irc_printf(conn, "TOPIC %s: %s\r\n", channel->name, str); else if (channel) irc_printf(conn, "TOPIC %s\r\n", channel->name); + else + goto not_in_channel; + return; + } + if (strcasecmp(arg0, "who") == 0) { + if (conn == NULL) + goto not_connected; + if (str == NULL && channel) + irc_printf(conn, "WHO %s\r\n", channel->name); + else if (str) + irc_printf(conn, "WHO %s\r\n", str); else goto not_in_channel; return; --- irc.h Thu Sep 5 21:21:10 2024 +++ irc.h Sun Sep 8 21:23:00 2024 @@ -28,7 +28,7 @@ enum { IRC_STATE_CONNECTED }; -#define IRC_MSG_MAX_ARGS 6 +#define IRC_MSG_MAX_ARGS 7 struct irc_msg { short code;