hirc

IRC client
Log | Files | Refs

commit 3b6ae4f4615a2ab417133782b2e93591b613db47
parent 7c5ee83ca6ccf74af43988feef23486a20988727
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 18 Dec 2021 17:34:28 +0000

s/commands.c s/config.c s/ui.c: /notice

Diffstat:
Msrc/commands.c | 29+++++++++++++++++++++++++++++
Msrc/config.c | 5+++++
Msrc/ui.c | 3+++
3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -29,6 +29,7 @@ #include "hirc.h" static void command_msg(struct Server *server, char *str); +static void command_notice(struct Server *server, char *str); static void command_query(struct Server *server, char *str); static void command_quit(struct Server *server, char *str); static void command_join(struct Server *server, char *str); @@ -68,6 +69,10 @@ struct Command commands[] = { "usage: /msg <nick|channel> message..", "Send a message to a nick or channel.", "Will appear in buffers if already open.", NULL}}, + {"notice", command_notice, 1, { + "usage: /notice <nick|channel> message..", + "Send a notice to a nick or channel.", + "Will appear in buffers if already open.", NULL}}, {"query", command_query, 1, { "usage: /query <nick>", "Open a buffer for communication with a nick", NULL}}, @@ -194,6 +199,30 @@ command_msg(struct Server *server, char *str) { } static void +command_notice(struct Server *server, char *str) { + struct Channel *chan = NULL; + char *target, *message; + + if (!str) { + ui_error("/notice requires argument", NULL); + return; + } + + target = strtok_r(str, " ", &message); + + if (serv_ischannel(server, target)) + chan = chan_get(&server->channels, target, -1); + else + chan = chan_get(&server->privs, target, -1); + + ircprintf(selected.server, "NOTICE %s :%s\r\n", target, message); + if (chan) { + hist_format(chan->history, Activity_self, + HIST_SHOW|HIST_LOG|HIST_SELF, "NOTICE %s :%s", target, message); + } +} + +static void command_query(struct Server *server, char *str) { struct Channel *priv; diff --git a/src/config.c b/src/config.c @@ -380,6 +380,11 @@ struct Config config[] = { .strhandle = config_redraws, .description = { "Format of messages", NULL}}, + {"format.notice", 1, Val_string, + .str = "%{nick:${nick}}-${nick}-%{o}%{=}${2}", + .strhandle = config_redraws, + .description = { + "Format of notices", NULL}}, {"format.join", 1, Val_string, .str = "%{b}%{c:44}+%{o}%{=}%{nick:${nick}}${nick}%{o} (${ident}@${host})", .strhandle = config_redraws, diff --git a/src/ui.c b/src/ui.c @@ -91,6 +91,7 @@ struct { {"SELF_HELP_END", "format.ui.help.end"}, /* Real commands/numerics from server */ {"PRIVMSG", "format.privmsg"}, + {"NOTICE", "format.notice"}, {"JOIN", "format.join"}, {"PART", "format.part"}, {"KICK", "format.kick"}, @@ -230,6 +231,8 @@ struct { {"003", "format.rpl.created"}, {"004", "format.rpl.myinfo"}, {"005", "format.rpl.isupport"}, + {"265", "format.rpl.localusers"}, + {"266", "format.rpl.globalusers"}, {"320", "format.rpl.whoisspecial"}, {"330", "format.rpl.whoisaccount"}, {"338", "format.rpl.whoisactually"},