aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-08 07:12:34 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-08 07:12:34 -0400
commitd19630bc7952a22acc11169be42f410e222fb904 (patch)
treebe4abca1b80cf09400a40862fd136bf450fff11b /src
parentfbc4daa87b2a6aaf355e2d3270d1ff726ab0ddae (diff)
downloadfujinet-chat-d19630bc7952a22acc11169be42f410e222fb904.tar.gz
Respond to incoming CTCPs.
Diffstat (limited to 'src')
-rw-r--r--src/irc.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/irc.c b/src/irc.c
index 3a57015..f5ac809 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -78,6 +78,54 @@ static void do_priv_nick(void) {
scr_print_active("* ");
}
+/* FIXME: this isn't very fast */
+static void do_ctcp(void) {
+ static char *p, *ctcp_type, *resp;
+
+ resp = 0;
+ ctcp_type = ++msg_text; /* skip leading ^A */
+
+ if( (p = strchr(msg_text, '\x01')) ) {
+ /* kill trailing ^A */
+ *p = 0;
+ }
+
+ if( (p = strchr(msg_text, ' ')) ) {
+ *p++ = 0;
+ }
+
+ if(streq_i(ctcp_type, "ACTION")) {
+ scr_print_active("* ");
+ scr_print_active(msg_src);
+ scr_print_active(" ");
+ scr_print_active(p);
+ scr_eol_active();
+ return;
+ }
+
+ scr_print_active("*** Got CTCP ");
+ scr_print_active(ctcp_type);
+ scr_print_active(" request from ");
+ scr_print_active(msg_src);
+ scr_eol_active();
+
+ if(streq_i(ctcp_type, "PING")) {
+ resp = p;
+ } else if(streq_i(ctcp_type, "CLIENTINFO")) {
+ resp = "PING VERSION CLIENTINFO";
+ } else if(streq_i(ctcp_type, "VERSION")) {
+ resp = "FujiNetChat pre-alpha on an Atari 8-bit";
+ } else {
+ /* unknown CTCP type, ignore */
+ return;
+ }
+
+ txbuf_set_str3("NOTICE ", msg_src, " :\x01");
+ txbuf_append_str3(ctcp_type, " ", resp);
+ txbuf_append_str("\x01");
+ txbuf_send();
+}
+
static void do_privmsg(void) {
/* TODO: this shouldn't be case-sensitive */
if(strstr(msg_text, usernick))
@@ -85,6 +133,11 @@ static void do_privmsg(void) {
else
hilite = 0;
+ if(*msg_text == '\x01') {
+ do_ctcp();
+ return;
+ }
+
if(*msg_dest == '#')
do_chan_nick();
else