From 1815d26c7042d3d592e624d8edf73805c7b3bc6d Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 8 Mar 2026 04:03:03 -0400 Subject: Send PMs to the correct window, more protocol stuff, add start+esc hotkey. --- src/irc.c | 81 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) (limited to 'src/irc.c') diff --git a/src/irc.c b/src/irc.c index 6a66f24..1f7aad3 100644 --- a/src/irc.c +++ b/src/irc.c @@ -95,16 +95,14 @@ static void do_privmsg(void) { static void do_join(void) { if(streq_i(usernick, msg_src)) { - /* if our nick is the source, create the screen if needed. if a - screen can't be created, no harm done. */ - if(scr_active == SCR_SERVER) - scr_create(msg_dest, 1); + scr_print_active("You have "); } else { scr_print_active(msg_src); - scr_print_active(" has joined "); - scr_print_active(msg_dest); - scr_eol_active(); + scr_print_active(" has "); } + scr_print_active("joined "); + scr_print_active(msg_dest); + scr_eol_active(); } static void do_nick(void) { @@ -158,11 +156,14 @@ static void do_kick(void) { static void do_mode(void) { int i; - scr_print_active(msg_src); + if(msg_src) + scr_print_active(msg_src); + else + scr_print_active("Server"); scr_print_active(" sets mode: "); for(i = 0; i < msg_argcount; i++) { - scr_print_active(" "); scr_print_active(msg_args[i]); + scr_print_active(" "); } if(msg_text) scr_print_active(msg_text); scr_eol_active(); @@ -227,16 +228,6 @@ static void do_numeric(void) { break; /* - case RPL_NAMREPLY: - "Users in ##channel", msg_text - - case RPL_TOPIC: - case RPL_NOTOPIC: - set the topic for the screen, if there is one - - case RPL_TOPICWHOTIME: - "Topic was set by ", don't try to parse the UNIX timestamp. - case RPL_WHOISCERTFP: case RPL_WHOISREGNICK: case RPL_WHOISUSER: @@ -252,16 +243,8 @@ static void do_numeric(void) { case RPL_WHOISSECURE: case RPL_WHOWASUSER: These always go to the server window. - - case RPL_ENDOFWHOIS: - case RPL_ENDOFWHOWAS: - Don't print. */ - case RPL_ENDOFNAMES: - /* don't print, just noise */ - break; - case ERR_NICKNAMEINUSE: do_catchall(0); if(!regged) { @@ -276,20 +259,29 @@ static void do_numeric(void) { case ERR_NOMOTD: break; + case RPL_NAMREPLY: + scr_print_active(msg_args[2]); + scr_print_active(" users: "); + scr_print_active(msg_text); + scr_print_active("\n"); + break; + + case RPL_ENDOFNAMES: + /* don't print, just noise */ + break; + case RPL_TOPIC: - s = scr_getbyname(msg_args[1]); - scr_print(s, "Topic for "); - scr_print(s, msg_args[1]); - scr_print(s, ": "); - scr_print(s, msg_text); - scr_putc(s, '\n'); + scr_print_active("Topic for "); + scr_print_active(msg_args[1]); + scr_print_active(": "); + scr_print_active(msg_text); + scr_print_active("\n"); break; case RPL_TOPICWHOTIME: - s = scr_getbyname(msg_args[1]); - scr_print(s, "Topic set by: "); - scr_print(s, msg_args[1]); - scr_putc(s, '\n'); + scr_print_active("Topic set by "); + scr_print_active(msg_args[2]); + scr_print_active("\n"); break; default: @@ -306,12 +298,19 @@ static void invalid_msg(char type) { void select_screen(void) { char s; - if(!msg_src || !msg_dest) { + if(!msg_dest) { s = SCR_SERVER; - } else { + } else if(*msg_dest == '#') { s = scr_getbyname(msg_dest); - if(!s && msg_dest[0] != '#') - s = SCR_PRIV; + if(!s) s = SCR_SERVER; + } else { + s = scr_getbyname(msg_src); + if(!s) { + if(streq_i(msg_cmd, "PRIVMSG")) /* or maybe NOTICE? */ + s = SCR_PRIV; + else + s = SCR_SERVER; + } } scr_activate(s); } -- cgit v1.2.3