[hackers] [ii] Give ii some more output for bot programming. || Christoph Lohmann

From: <git_AT_suckless.org>
Date: Wed, 19 Nov 2025 21:27:29 +0100 (CET)

commit 4710bc9f42827fe8a81c3fc3b67d5dcb0dcfb250
Author: Christoph Lohmann <20h_AT_r-36.net>
AuthorDate: Wed Nov 19 19:20:25 2025 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Wed Nov 19 21:22:35 2025 +0100

    Give ii some more output for bot programming.
    
    By outputting raw IRC commands on channelmaster and some more debug on
    PONG etc., it is easier to write bots with ii.
    
    See git://bitreich.org/annna for an example.

diff --git a/ii.c b/ii.c
index f0c7b4d..d89c962 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -577,6 +577,7 @@ proc_server_cmd(int fd, char *buf)
         char *argv[TOK_LAST], *cmd = NULL, *p = NULL;
         unsigned int i;
 
+ channel_print(channelmaster, buf);
         if (!buf || buf[0] == '\0')
                 return;
 
_AT_@ -615,9 +616,13 @@ proc_server_cmd(int fd, char *buf)
         tokenize(&argv[TOK_CMD], TOK_LAST - TOK_CMD, cmd, ' ');
 
         if (!argv[TOK_CMD] || !strcmp("PONG", argv[TOK_CMD])) {
+ snprintf(msg, sizeof(msg), "-!- %s %s", argv[TOK_CMD], argv[TOK_TEXT]);
+ channel_print(channelmaster, msg);
                 return;
         } else if (!strcmp("PING", argv[TOK_CMD])) {
+ channel_print(channelmaster, "-!- sending PONG to PING request");
                 snprintf(msg, sizeof(msg), "PONG %s\r\n", argv[TOK_TEXT]);
+ channel_print(channelmaster, msg);
                 ewritestr(fd, msg);
                 return;
         } else if (!argv[TOK_NICKSRV] || !argv[TOK_USER]) {
_AT_@ -674,6 +679,8 @@ proc_server_cmd(int fd, char *buf)
                 snprintf(msg, sizeof(msg), "<%s> %s", argv[TOK_NICKSRV],
                                 argv[TOK_TEXT] ? argv[TOK_TEXT] : "");
         } else {
+ snprintf(msg, sizeof(msg), "-!- unknown cmd %s", argv[TOK_TEXT]);
+ channel_print(channelmaster, msg);
                 return; /* can't read this message */
         }
         if (argv[TOK_CHAN] && !strcmp(argv[TOK_CHAN], nick))
Received on Wed Nov 19 2025 - 21:27:29 CET

This archive was generated by hypermail 2.3.0 : Wed Nov 19 2025 - 21:36:37 CET