Simplest way to show user messages from an irc channel in a terminal - Servers Administration, Networking, & Virtualization

Users browsing this thread: 1 Guest(s)
josuah
Long time nixers
And then come the fun part (4th piece): ricing ii output. What I like is that all consecutive messages from a single person get grouped, and that a newline gets added whenever the speaker change:

Sample output:

Code:
---------------------------------- 2017-05-20 ----------------------------------

23:38     person  I write a message
23:39             then another one, and it is added below, without repeating
                  the nick name.  And if it is too long, it gets wrapped,
                  without repeating the date

23:44       dude  I am another person, empty line gets added above.

23:46        -!-  someone(~user@somewhere) has joined #unix
23:48             other-dude(~user@somewhere.else) has joined #unix

23:56       dude  whoops!
23:57             close to a new day!

---------------------------------- 2017-05-20 ----------------------------------

00:01       dude  Yup! The day is over.  Long life to the day!

The source of the ii wrapper: it takes input from stdin and spat it out as it comes:
Code:
# http://tools.suckless.org/ii

awk '

BEGIN {
    WIDTH = 80 - 17;
}

{
    last = date;
    date = $1;
}

date != last {
    printf("----------------------------------");
    printf(" %s ", date);
    printf("----------------------------------\n")
}

{
    if ($3 ~ "<.*>" || $3 ~ "-!-") {
        sub("<", "", $3);
        sub(">", "", $3);

        if (nick != $3) {
            printf("\n");
            printf("%s %10s  ", $2, $3);
            nick = $3;
        } else {
            printf("%s %10s  ", $2, "");
        }

        sub("[^ ]* [^ ]* [^ ]* ", "");

    } else {
        printf("%s %10s  ", $2, "");
        sub("[^ ]* [^ ]* ", "");
    }

    sub("^\001ACTION ", "~~ ");
    sub("\001$", " ~~");

    for (offset = 0; length($0) > 0; offset = 18) {
        row = substr($0, 1, WIDTH);

        if (length(row) >= WIDTH)
            sub(" [^ ]*$", "", row);

        $0 = substr($0, length(row) + 1);
        sub(" *", "");

        printf("%" offset "s%s\n", "", row);
    }
}'


Messages In This Thread
RE: Simplest way to show user messages from an irc channel in a terminal - by josuah - 22-05-2017, 06:40 PM