commit c232f69e8a94cfff3a57a5220fdf213cf1c177ef
parent 56c432d12374cee54767c4a9f948b6f9a27104be
Author: hhvn <dev@hhvn.uk>
Date: Sat, 18 Dec 2021 12:36:28 +0000
s/commands.c s/config.c s/ui.c: /whois
Diffstat:
3 files changed, 75 insertions(+), 16 deletions(-)
diff --git a/src/commands.c b/src/commands.c
@@ -34,6 +34,7 @@ static void command_join(struct Server *server, char *str);
static void command_part(struct Server *server, char *str);
static void command_kick(struct Server *server, char *str);
static void command_mode(struct Server *server, char *str);
+static void command_whois(struct Server *server, char *str);
static void command_ping(struct Server *server, char *str);
static void command_quote(struct Server *server, char *str);
static void command_connect(struct Server *server, char *str);
@@ -82,6 +83,9 @@ struct Command commands[] = {
{"mode", command_mode, 1, {
"usage: /mode <channel> modes...",
"Set/unset channel modes", NULL}},
+ {"whois", command_whois, 1, {
+ "usage: /whois [server] [nick]",
+ "Request information on a nick or oneself", NULL}},
{"ping", command_ping, 1, {
"usage: /ping message...",
"Send a PING to server.",
@@ -300,6 +304,27 @@ command_mode(struct Server *server, char *str) {
}
static void
+command_whois(struct Server *server, char *str) {
+ char *tserver, *nick;
+
+ if (!str) {
+ nick = server->self->nick;
+ tserver = NULL;
+ } else {
+ tserver = strtok_r(str, " ", &nick);
+ if (!nick || !*nick) {
+ nick = tserver;
+ tserver = NULL;
+ }
+ }
+
+ if (tserver)
+ ircprintf(server, "WHOIS %s %s\r\n", tserver, nick);
+ else
+ ircprintf(server, "WHOIS %s\r\n", nick);
+}
+
+static void
command_ping(struct Server *server, char *str) {
if (!str) {
ui_error("/ping requires argument", NULL);
diff --git a/src/config.c b/src/config.c
@@ -648,17 +648,17 @@ struct Config config[] = {
.description = {
"Format of RPL_NOWAWAY (306) numeric", NULL}},
{"format.rpl.whoisuser", 1, Val_string,
- .str = "${2-}",
+ .str = "%{b}${2}!${3}@${4}%{b} (${6}):",
.strhandle = config_redraws,
.description = {
"Format of RPL_WHOISUSER (311) numeric", NULL}},
{"format.rpl.whoisserver", 1, Val_string,
- .str = "${2-}",
+ .str = " %{b}server %{b}: ${3} (${4})",
.strhandle = config_redraws,
.description = {
"Format of RPL_WHOISSERVER (312) numeric", NULL}},
{"format.rpl.whoisoperator", 1, Val_string,
- .str = "${2-}",
+ .str = " %{b}oper %{b}: ${3}",
.strhandle = config_redraws,
.description = {
"Format of RPL_WHOISOPERATOR (313) numeric", NULL}},
@@ -672,23 +672,18 @@ struct Config config[] = {
.strhandle = config_redraws,
.description = {
"Format of RPL_ENDOFWHO (315) numeric", NULL}},
- {"format.rpl.whoischanop", 1, Val_string,
- .str = "${2-}",
- .strhandle = config_redraws,
- .description = {
- "Format of RPL_WHOISCHANOP (316) numeric", NULL}},
{"format.rpl.whoisidle", 1, Val_string,
- .str = "${2-}",
+ .str = " %{b}idle %{b}: ${3} seconds",
.strhandle = config_redraws,
.description = {
"Format of RPL_WHOISIDLE (317) numeric", NULL}},
{"format.rpl.endofwhois", 1, Val_string,
- .str = "${2-}",
+ .str = "",
.strhandle = config_redraws,
.description = {
"Format of RPL_ENDOFWHOIS (318) numeric", NULL}},
{"format.rpl.whoischannels", 1, Val_string,
- .str = "${2-}",
+ .str = " %{b}channels%{b}: ${3}",
.strhandle = config_redraws,
.description = {
"Format of RPL_WHOISCHANNELS (319) numeric", NULL}},
@@ -1078,6 +1073,38 @@ struct Config config[] = {
.description = {
"Format of ERR_USERSDONTMATCH (502) numeric", NULL}},
/* END: misc/rpl-conf-gen.awk */
+ /* Modern numerics */
+ {"format.rpl.whoisspecial", 1, Val_string,
+ .str = " %{b}info %{b}: ${3}",
+ .strhandle = config_redraws,
+ .description = {
+ "Format of RPL_WHOISSPECIAL (320) numeric", NULL}},
+ {"format.rpl.whoisaccount", 1, Val_string,
+ .str = " %{b}account %{b}: ${3}",
+ .strhandle = config_redraws,
+ .description = {
+ "Format of RPL_WHOISACCOUNT (330) numeric", NULL}},
+ {"format.rpl.whoisactually", 1, Val_string,
+ .str = " %{b}actually%{b}: ${3-}",
+ .strhandle = config_redraws,
+ .description = {
+ "Format of RPL_WHOISACTUALLY (338) numeric", NULL}},
+ {"format.rpl.whoishost", 1, Val_string,
+ .str = " %{b}info %{b}: ${3}",
+ .strhandle = config_redraws,
+ .description = {
+ "Format of RPL_WHOISHOST (378) numeric", NULL}},
+ {"format.rpl.whoismodes", 1, Val_string,
+ .str = " %{b}modes %{b}: ${3}",
+ .strhandle = config_redraws,
+ .description = {
+ "Format of RPL_WHOISMODES (379) numeric", NULL}},
+ {"format.rpl.whoissecure", 1, Val_string,
+ .str = " %{b}secure %{b}: ${3}",
+ .strhandle = config_redraws,
+ .description = {
+ "Format of RPL_WHOISSECURE (671) numeric", NULL}},
+ /* Default formats */
{"format.rpl.other", 1, Val_string,
.str = "${cmd} ${2-}",
.strhandle = config_redraws,
diff --git a/src/ui.c b/src/ui.c
@@ -95,11 +95,6 @@ struct {
{"PART", "format.part"},
{"KICK", "format.kick"},
{"QUIT", "format.quit"},
- {"001", "format.rpl.welcome"},
- {"002", "format.rpl.yourhost"},
- {"003", "format.rpl.created"},
- {"004", "format.rpl.myinfo"},
- {"005", "format.rpl.isupport"},
/* START: misc/rpl-ui-gen.awk */
{"200", "format.rpl.tracelink"},
{"201", "format.rpl.traceconnecting"},
@@ -229,6 +224,18 @@ struct {
{"501", "format.err.umodeunknownflag"},
{"502", "format.err.usersdontmatch"},
/* END: misc/rpl-ui-gen.awk */
+ /* Modern stuff */
+ {"001", "format.rpl.welcome"},
+ {"002", "format.rpl.yourhost"},
+ {"003", "format.rpl.created"},
+ {"004", "format.rpl.myinfo"},
+ {"005", "format.rpl.isupport"},
+ {"320", "format.rpl.whoisspecial"},
+ {"330", "format.rpl.whoisaccount"},
+ {"338", "format.rpl.whoisactually"},
+ {"378", "format.rpl.whoishost"},
+ {"379", "format.rpl.whoismodes"},
+ {"671", "format.rpl.whoissecure"},
/* Pseudo commands for specific formatting */
{"MODE-NICK-SELF", "format.mode.nick.self"},
{"MODE-NICK", "format.mode.nick"},