From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pb-smtp2.pobox.com ([64.147.108.71]) by ewsd; Tue May 5 03:43:53 EDT 2020 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 964B951B85 for <9front@9front.org>; Tue, 5 May 2020 03:43:40 -0400 (EDT) (envelope-from unobe@cpan.org) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date :in-reply-to:references:mime-version:content-type :content-transfer-encoding:subject:to:from:message-id; s=sasl; bh=sL4jcXYKd5EMjc5SPi9FntP+gno=; b=kdPPkLroT++dGeZUKhJLAVmBq3GR MAJWq7VCZorzosRfvaIt7Ez7Vq62IC8chL1qrzLbSOlJdXolkMD9JBaH0w5jKkOx ssTUfWtfAFQLJ24yHYb4VW8s89VwrlTW7S8KclE2k2lanaKMcwLTLMgWvsE2gfbC rbhsXOk8BArS8hc= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 8F17B51B84 for <9front@9front.org>; Tue, 5 May 2020 03:43:40 -0400 (EDT) (envelope-from unobe@cpan.org) Received: from [10.0.1.31] (unknown [137.25.138.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id CF9DC51B83 for <9front@9front.org>; Tue, 5 May 2020 03:43:39 -0400 (EDT) (envelope-from unobe@cpan.org) Date: Tue, 05 May 2020 07:43:35 +0000 In-Reply-To: <29C755ECA38798261162073E8677BA15@eigenstate.org> References: <29C755ECA38798261162073E8677BA15@eigenstate.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9front] Re: [patch] format messages for ircrc To: 9front@9front.org From: Romano Message-ID: <26E4B111-656D-433B-B9A5-5D64A8DD47BF@cpan.org> X-Pobox-Relay-ID: 22D9254C-8EA4-11EA-8E2A-D1361DBA3BAF-09620299!pb-smtp2.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: extended anonymous module TOR over XMPP app STM manager Thanks Ori! I've updated the patch and tested it: see below (and it's also at http://o= kturing=2Ecom/src/8458/body)=2E Note that 512 is the # of characters includ= ing the hostname (63 chars), command, the actual text message, and the fina= l CR&LF required by the protocol=2E So the # of characters allowed per mess= age text is 447, which I mention in the man page=2E On Mon, May 4, 2020, at 8:38 PM, ori@eigenstate=2Eorg wrote: > > Ping=2E Perhaps the -l option is too much=2E >=20 > Agreed -- I'd compute it=2E That would probably look something like: >=20 > linelen =3D `{hoc -e '510 - '`{echo 'PRIVMSG '^$target^' :' | wc -c }} >=20 > Another small bit of nitpicking (I'd be ok with committing it as is, but > I may as well register my preferences: >=20 > > + msg=3D($msg^' > > +PRIVMSG '^$target^' :'^$"cmd) >=20 >=20 > I'd do this somewhere near the start of the program: >=20 > nl=3D' > ' >=20 > And construct strings using it like this: >=20 > msg=3D($msg^$nl^'PRIVMSG '^$target^' :'^$"cmd) >=20 > Other than that, this looks fine to me=2E >=20 diff -r 0ee17db5d86b rc/bin/ircrc --- a/rc/bin/ircrc Sat May 02 17:32:01 2020 +0200 +++ b/rc/bin/ircrc Tue May 05 00:36:54 2020 -0700 @@ -49,71 +49,86 @@ echo QUIT : Leaving=2E=2E=2E > $netdir/data exit } - msg=3D() - out=3D() - switch ($cmd(1)) { - case /! - eval `{mshift $cmd} | while(rc=3D`{read})echo 'PRIVMSG '^$target^' :' = $rc | tee $netdir/data - case /M - msg =3D (MODE `{mshift $cmd}) - case /N + do_cmd + } +} + +fn do_cmd { + msg=3D() + out=3D() + switch ($cmd(1)) { + case /! + eval `{mshift $cmd} | while(rc=3D`{read})echo 'PRIVMSG '^$target^' :' $= rc | tee $netdir/data + case /M + msg =3D (MODE `{mshift $cmd}) + case /N + cmd =3D `{mshift $cmd} + if (! ~ $#cmd 0) + msg =3D (NOTICE $cmd(1) : `{mshift $cmd}) + case /T + msg =3D (TOPIC `{mshift $cmd}) + case /W + msg =3D (WHOIS `{mshift $cmd}) + case /a + msg =3D (AWAY : `{mshift $cmd}) + case /j + if (~ $#cmd 2) { + target=3D$cmd(2) + title + msg =3D (JOIN `{mshift $cmd}) + if(~ $target *,*) + target =3D `{echo $target | awk -F',' '{print $NF}'} + } + case /l + msg =3D (LIST `{mshift $cmd}) + case /m + cmd =3D `{mshift $cmd} + if (! ~ $#cmd 0) { + target_orig=3D$target + target =3D $cmd(1) cmd =3D `{mshift $cmd} - if (! ~ $#cmd 0) - msg =3D (NOTICE $cmd(1) : `{mshift $cmd}) - case /T - msg =3D (TOPIC `{mshift $cmd}) - case /W - msg =3D (WHOIS `{mshift $cmd}) - case /a - msg =3D (AWAY : `{mshift $cmd}) - case /j - if (~ $#cmd 2) { - target=3D$cmd(2) - title - msg =3D (JOIN `{mshift $cmd}) - if(~ $target *,*) - target =3D `{echo $target | awk -F',' '{print $NF}'} - } - case /l - msg =3D (LIST `{mshift $cmd}) - case /m - cmd =3D `{mshift $cmd} - if (! ~ $#cmd 0) { - to =3D $cmd(1) - cmd =3D `{mshift $cmd} - out =3D '('^$to^') =E2=87=90 '^$"cmd - msg =3D 'PRIVMSG '^$to^' :'^$"cmd - } - case /n - nick =3D `{mshift $cmd} - msg =3D (NICK $nick) - case /p - cmd =3D `{mshift $cmd} - if (! ~ $#cmd 0) - msg =3D (PART $cmd(1) : `{mshift $cmd}) - case /q - msg =3D `{mshift $cmd} - case /t - target =3D `{mshift $cmd} - title - case /u - msg =3D (USERS `{mshift $cmd}) - case /w - msg =3D (WHO `{mshift $cmd}) - case /x - echo QUIT : Leaving=2E=2E=2E > $netdir/data - exit - case /* - echo unknown command - case * - msg =3D 'PRIVMSG '^$target^' :'^$"cmd - out =3D '('^$target^') =E2=87=90 '^$"cmd + send_msg + target=3D$target_orig } - if (! ~ $#msg 0) - echo $msg > $netdir/data - if (! ~ $#out 0) - echo `{etime}^' '^$out + case /n + nick =3D `{mshift $cmd} + msg =3D (NICK $nick) + case /p + cmd =3D `{mshift $cmd} + if (! ~ $#cmd 0) + msg =3D (PART $cmd(1) : `{mshift $cmd}) + case /q + msg =3D `{mshift $cmd} + case /t + target =3D `{mshift $cmd} + title + case /u + msg =3D (USERS `{mshift $cmd}) + case /w + msg =3D (WHO `{mshift $cmd}) + case /x + echo QUIT : Leaving=2E=2E=2E > $netdir/data + exit + case /* + echo unknown command + case * + send_msg } + if (! ~ $#msg 0) + echo $msg > $netdir/data + if (! ~ $#out 0) + echo `{etime}^' '^$out +} + +fn send_msg { + prefixmsg=3D'PRIVMSG '^$target^' :' + prefixout=3D'('^$target^') =E2=87=90 ' + linelen=3D`{hoc -e 447^'-'^`{echo -n $prefixmsg | wc -c} } + ifs_orig=3D$ifs + ifs=3D'=04' + msg=3D`{echo -n $cmd | fmt -l $linelen | awk '{ printf "%s%s\n", ENVIRON= ["prefixmsg"], $0 }' } + out=3D`{echo $msg | sed s/$prefixmsg/$prefixout/ } + ifs=3D$ifs_orig } =20 fn misc { diff -r 0ee17db5d86b sys/man/1/ircrc --- a/sys/man/1/ircrc Sat May 02 17:32:01 2020 +0200 +++ b/sys/man/1/ircrc Tue May 05 00:36:54 2020 -0700 @@ -152,6 +152,10 @@ command=2E Control-D also sends this command=2E =2EPP +Any message containing more than the protocol's maximum allowed character= s (447) is chunked into multiple messages using +=2EI fmt(1) +=2E +=2EPP See RFC 1459 and RFC 2812 for detailed information about IRC commands=2E =2ESH EXAMPLES