aboutsummaryrefslogtreecommitdiff
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
parentfbc4daa87b2a6aaf355e2d3270d1ff726ab0ddae (diff)
downloadfujinet-chat-d19630bc7952a22acc11169be42f410e222fb904.tar.gz
Respond to incoming CTCPs.
-rw-r--r--commands.txt20
-rw-r--r--src/irc.c53
2 files changed, 72 insertions, 1 deletions
diff --git a/commands.txt b/commands.txt
index 9641d6d..eb7fa0b 100644
--- a/commands.txt
+++ b/commands.txt
@@ -16,6 +16,11 @@ Joins a channel, creates a new screen if possible. If a screen can't
be created, channel text will be sent to the [server] screen, and
"/m #channel" must be used, to send to the channel.
+/j1 <channel>
+/join1 <channel>
+Joins a channel without creating a new screen. Channel test will be
+sent to the [server] screen. Use "/m #channel" to send to the channel.
+
/m <nick|channel> <text>
/msg <nick|channel> <text>
PRIVMSG to nick or channel.
@@ -36,11 +41,21 @@ Parts (leaves) a channel. If no #chan is given, the current screen's
channel is parted (if you're in a channel screen). If there's a screen
for the channel, it gets closed.
+/names [<channel>]
+Shows the list of users in a channel. Uses the current screen's channel,
+if no <channel> given. On most networks, it's not very useful to use
+/names on a channel you haven't joined.
+
+/topic [<channel>]
+Shows the channel topic and its creator. With no <channel>, uses the
+current screen's channel.
+
/ping [<nick>]
With no argument: ping the server. With arg: CTCP ping the nick.
The contents of RTCLOK are sent as the ping data, so when the
PONG response is received, the round-trip time can be shown, with
up to 1/60 (NTSC) or 1/50 (PAL) second accuracy.
+TODO: not implemented yet.
/me <action>
CTCP ACTION. Only works in a channel or query screen (eventually
@@ -60,10 +75,13 @@ any arguments lists every channel on the server, which isn't useful.
/color <bg> [<fg>] [<status-active>] [<status-highlight>]
Set colors. This should be on a per-screen basis, eventually.
+TODO: this only takes bg and fg arguments, currently.
/chans
List all channels we've joined. This will actually be limited to
something like 20 (who joins more than 20 channels anyway?)
+TODO: not implemented yet.
/quote <cmd>
-Send raw IRC protocol.
+Send raw IRC protocol to the server. This bypasses local command
+parsing.
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