From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pb-smtp21.pobox.com ([173.228.157.53]) by ewsd; Tue Apr 21 04:14:04 EDT 2020 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id BC7BCB2AA1 for <9front@9front.org>; Tue, 21 Apr 2020 04:13:55 -0400 (EDT) (envelope-from unobe@cpan.org) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date :mime-version:content-type:content-transfer-encoding:subject:to :from:message-id; s=sasl; bh=GOsbxufAztgyCbw/sj/WMzeZ2ig=; b=bkd T+7sJrY15+Qrz4kFpRF+zzG1DJvRA+tkmMCplwRAWFWHRLypc562fBPKWqrSYbav h4hZpvYqzHTL+G4EquEY/gQX2MOO9i41V1M67JBGMTo81SsSx7V0s3OxQ5zrsaLF 8FYVlKFjA9q4bdTHM8ICxKiAGCSraOMS31N4lqG4= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id A5E39B2AA0 for <9front@9front.org>; Tue, 21 Apr 2020 04:13:55 -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-smtp21.pobox.com (Postfix) with ESMTPSA id C0A0DB2A9F for <9front@9front.org>; Tue, 21 Apr 2020 04:13:52 -0400 (EDT) (envelope-from unobe@cpan.org) Date: Tue, 21 Apr 2020 08:13:49 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [patch] format messages for ircrc To: 9front@9front.org From: Romano Message-ID: <53C204F0-418F-4042-9D9E-9C475D4E85E8@cpan.org> X-Pobox-Relay-ID: 09A87ED0-83A8-11EA-B6B5-8D86F504CC47-09620299!pb-smtp21.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: overflow-preventing optimized persistence generator 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 ta= rget] [-n nick] [-T] [server]' >[1=3D2] + echo 'usage: ircrc [-p port] [-P server password] [-r realname] [-t ta= rget] [-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 fm= t 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