From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pb-smtp1.pobox.com ([64.147.108.70]) by ewsd; Fri Jun 12 20:09:28 EDT 2020 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 448D27D6E2 for <9front@9front.org>; Fri, 12 Jun 2020 20:09:15 -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=TtfPIbGAbjCaZFcdXSa736c+eSg=; b=ZoQTdd6mWKGUIxAzngwKb167nwOc IfZ243VVthP4otPFFWsdpvoA5qIAw2vEKuuAhoW/A6PLbOZk+1m5zkc2Fw5duBc7 tNvHqBEmBkfsgK9j3nkrKe+icgupXMUm6J7GUy6PXA2AW3D00fqHJGPiErcDjcg9 G60wgoQXGxy8maI= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 3C5697D6E1 for <9front@9front.org>; Fri, 12 Jun 2020 20:09:15 -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-smtp1.pobox.com (Postfix) with ESMTPSA id 5364F7D6E0 for <9front@9front.org>; Fri, 12 Jun 2020 20:09:14 -0400 (EDT) (envelope-from unobe@cpan.org) Date: Sat, 13 Jun 2020 00:09:11 +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: <9D0674A7-66F2-4AE0-8FC6-608933FCB121@cpan.org> X-Pobox-Relay-ID: 1D72802E-AD0A-11EA-B8A4-C28CBED8090B-09620299!pb-smtp1.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: virtual patented API HTTP grid-based cloud polling content-driven frontend [Re-sending] 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