hirc

IRC client
Log | Files | Refs

commit 2aa591bdb96470cc08e54bb046a7bb354d136861
parent 5cbdfebb44e812d137c624a53d1d09fdbb506bc3
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 27 Mar 2022 11:53:17 +0100

Add fake QUIT messages on /disconnect

Diffstat:
Msrc/commands.c | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -869,8 +869,9 @@ command_connect) { COMMAND( command_disconnect) { struct Server *sp; + struct Channel *chp; int len; - char *msg; + char *msg = NULL; if (str) { len = strcspn(str, " "); @@ -886,13 +887,21 @@ command_disconnect) { if (sp == NULL) { sp = server; msg = str; - return; } } else sp = server; if (!msg || !*msg) - msg = config_gets("def.quitmessage"); + msg = config_gets("misc.quitmessage"); + /* Add fake quit messages to history. + * Theoretically, we could send QUIT and then wait for a + * reply, but I don't see the advantage. (Unless the + * server fucks with our quit messages somehow). + * + * Since HIST_SELF is used, there is no need to fake a prefix. */ + hist_format(sp->history, Activity_self, HIST_DFL|HIST_SELF, "QUIT :%s", msg); + for (chp = sp->channels; chp; chp = chp->next) + hist_format(chp->history, Activity_self, HIST_DFL|HIST_SELF, "QUIT :%s", msg); serv_disconnect(sp, 0, msg); }