commit c3257a06aa015370b4b6c50151789f2404819e20
parent c232f69e8a94cfff3a57a5220fdf213cf1c177ef
Author: hhvn <dev@hhvn.uk>
Date: Sat, 18 Dec 2021 12:58:49 +0000
s/commands.c s/config.c: /whowas
Diffstat:
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/commands.c b/src/commands.c
@@ -35,6 +35,7 @@ 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_whowas(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);
@@ -86,6 +87,10 @@ struct Command commands[] = {
{"whois", command_whois, 1, {
"usage: /whois [server] [nick]",
"Request information on a nick or oneself", NULL}},
+ {"whowas", command_whowas, 1, {
+ "usage: /whowas [nick [count [server]]]",
+ "Request information on old nicks",
+ "Count defaults to 5", NULL}},
{"ping", command_ping, 1, {
"usage: /ping message...",
"Send a PING to server.",
@@ -319,12 +324,32 @@ command_whois(struct Server *server, char *str) {
}
if (tserver)
- ircprintf(server, "WHOIS %s %s\r\n", tserver, nick);
+ ircprintf(server, "WHOIS %s :%s\r\n", tserver, nick);
else
ircprintf(server, "WHOIS %s\r\n", nick);
}
static void
+command_whowas(struct Server *server, char *str) {
+ char *nick, *count, *tserver;
+
+ if (!str) {
+ nick = server->self->nick;
+ count = tserver = NULL;
+ } else {
+ nick = strtok_r(str, " ", &tserver);
+ count = strtok_r(NULL, " ", &tserver);
+ }
+
+ if (tserver)
+ ircprintf(server, "WHOWAS %s %s :%s\r\n", nick, count, tserver);
+ else if (count)
+ ircprintf(server, "WHOWAS %s %s\r\n", nick, count);
+ else
+ ircprintf(server, "WHOWAS %s 5\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
@@ -663,7 +663,7 @@ struct Config config[] = {
.description = {
"Format of RPL_WHOISOPERATOR (313) numeric", NULL}},
{"format.rpl.whowasuser", 1, Val_string,
- .str = "${2-}",
+ .str = "%{b}${2}!${3}@${4}%{b} (${6}) was on:",
.strhandle = config_redraws,
.description = {
"Format of RPL_WHOWASUSER (314) numeric", NULL}},
@@ -773,7 +773,7 @@ struct Config config[] = {
.description = {
"Format of RPL_ENDOFBANLIST (368) numeric", NULL}},
{"format.rpl.endofwhowas", 1, Val_string,
- .str = "${2-}",
+ .str = "",
.strhandle = config_redraws,
.description = {
"Format of RPL_ENDOFWHOWAS (369) numeric", NULL}},