From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pb-smtp20.pobox.com ([173.228.157.52]) by ewsd; Mon May 4 23:08:58 EDT 2020 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id B5F80DEEE1 for <9front@9front.org>; Mon, 4 May 2020 23:08:45 -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=+ZlNteiR4jpRZJ0Iws1zYBEIWn0=; b=CGKSD/Ms5+NZ9pQMCym1GqaOQIAb HoVWP6rvASzblPoUeqYz14C5qFIMxUbIOfdpUDuo4ytuj9PkmlDyGRisDaUKmxXA wB6put1MIwS4BLzG5BHIDjw4NaHWNW/gUYaJewUi+u6MSP5Z00hfPD0pfKEX/Gbn IBD/QaEWKX/0sHI= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id AE43DDEEE0 for <9front@9front.org>; Mon, 4 May 2020 23:08:45 -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-smtp20.pobox.com (Postfix) with ESMTPSA id DB4DADEEDF for <9front@9front.org>; Mon, 4 May 2020 23:08:42 -0400 (EDT) (envelope-from unobe@cpan.org) Date: Tue, 05 May 2020 03:08:37 +0000 In-Reply-To: <53C204F0-418F-4042-9D9E-9C475D4E85E8@cpan.org> References: <53C204F0-418F-4042-9D9E-9C475D4E85E8@cpan.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [patch] format messages for ircrc To: 9front@9front.org From: Romano Message-ID: X-Pobox-Relay-ID: B9E57B88-8E7D-11EA-B9BC-B0405B776F7B-09620299!pb-smtp20.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: asynchronous engine-scale singleton Ping=2E Perhaps the -l option is too much=2E The whitespace below doesn't s= eem preserved, so I can post to okturing if needed=2E On April 21, 2020 8:13:49 AM UTC, Romano wrote: >On #cat-v earlier, some of my messages were being chopped off=2E There >was a discussion about possible ways to correct it using fmt=2E This >patch adds a default message length of 100 and processes messages >through fmt=2E > > >diff -r f9f922fd127d rc/bin/ircrc >--- a/rc/bin/ircrc Mon Apr 20 00:08:35 2020 +0200 >+++ b/rc/bin/ircrc Tue Apr 21 01:03:56 2020 -0700 >@@ -11,6 +11,7 @@ > pass=3D() > tls=3D0 > serverpass=3D() >+msglen=3D100 >=20 > fn sighup { > exit 'hang up' >@@ -49,70 +50,100 @@ > 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) { >+ to =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}'} >+ 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 * >+ send_msg >+ } >+ if (! ~ $#msg 0) >+ echo $msg > $netdir/data >+ if (! ~ $#out 0) >+ echo `{etime}^' '^$out >+} >+ >+fn send_msg { >+ if (test `{echo -n $cmd | wc -c} -gt $msglen) { >+ ifs_orig=3D$ifs >+ ifs=3D' >+' >+ msgs=3D`{echo -n $cmd | fmt -l $msglen} >+ ifs=3D$ifs_orig >+ for (cmd in $msgs) { >+ if (~ $#msg 0 ) { >+ msg=3D('PRIVMSG '^$target^' :'^$"cmd) >+ out=3D('('^$target^') =E2=87=90 '^$"cmd) > } >- 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 >+ if not { >+ msg=3D($msg^' >+PRIVMSG '^$target^' :'^$"cmd) >+ out=3D($out^' >+('^$target^') =E2=87=90 '^$"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 > } >- if (! ~ $#msg 0) >- echo $msg > $netdir/data >- if (! ~ $#out 0) >- echo `{etime}^' '^$out >+ msgs=3D() >+ } >+ if not { >+ msg =3D 'PRIVMSG '^$target^' :'^$"cmd >+ out =3D '('^$target^') =E2=87=90 '^$"cmd > } > } >=20 >@@ -211,10 +242,13 @@ > case -t > target=3D$2 > shift >+ case -l >+ msglen=3D$2 >+ shift > case -T > tls=3D1 > case -* >- echo 'usage: ircrc [-p port] [-P server password] [-r realname] [-t >target] [-n nick] [-T] [server]' >[1=3D2] >+ echo 'usage: ircrc [-p port] [-P server password] [-r realname] [-t >target] [-n nick] [-l message format length] [-T] [server]' >[1=3D2] > exit 'usage'=09 > } > shift >diff -r f9f922fd127d sys/man/1/ircrc >--- a/sys/man/1/ircrc Mon Apr 20 00:08:35 2020 +0200 >+++ b/sys/man/1/ircrc Tue Apr 21 01:03:56 2020 -0700 >@@ -23,6 +23,9 @@ > =2EB -n > =2EI nick > ] >+=2EB -l >+=2EI message format length >+] > [ > =2EB -T > ] [ >@@ -70,6 +73,10 @@ > Change the default nickname > =2ERB ( $user )=2E > =2ETP >+=2EBI -l " length >+Change the message formatting length, piping the messages sent through >fmt with the given length=2E The maximum broken UTF code length is around >510: messages may chopped if set higher=2E >+=2ERB ( 100 )=2E >+=2ETP > =2EBI -T > =2Ebr > Use tls through