From: Romano <unobe@cpan.org>
To: 9front@9front.org
Subject: Re: [patch] format messages for ircrc
Date: Tue, 05 May 2020 03:08:37 +0000 [thread overview]
Message-ID: <A5BFDE79-0CD5-4CD4-B1CE-332C2DB5FFE3@cpan.org> (raw)
In-Reply-To: <53C204F0-418F-4042-9D9E-9C475D4E85E8@cpan.org>
Ping. Perhaps the -l option is too much. The whitespace below doesn't seem preserved, so I can post to okturing if needed.
On April 21, 2020 8:13:49 AM UTC, Romano <unobe@cpan.org> wrote:
>On #cat-v earlier, some of my messages were being chopped off. There
>was a discussion about possible ways to correct it using fmt. This
>patch adds a default message length of 100 and processes messages
>through fmt.
>
>
>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=()
> tls=0
> serverpass=()
>+msglen=100
>
> fn sighup {
> exit 'hang up'
>@@ -49,70 +50,100 @@
> echo QUIT : Leaving... > $netdir/data
> exit
> }
>- msg=()
>- out=()
>- switch ($cmd(1)) {
>- case /!
>- eval `{mshift $cmd} | while(rc=`{read})echo 'PRIVMSG '^$target^' :'
>$rc | tee $netdir/data
>- case /M
>- msg = (MODE `{mshift $cmd})
>- case /N
>+ do_cmd
>+ }
>+}
>+
>+fn do_cmd {
>+ msg=()
>+ out=()
>+ switch ($cmd(1)) {
>+ case /!
>+ eval `{mshift $cmd} | while(rc=`{read})echo 'PRIVMSG '^$target^' :'
>$rc | tee $netdir/data
>+ case /M
>+ msg = (MODE `{mshift $cmd})
>+ case /N
>+ cmd = `{mshift $cmd}
>+ if (! ~ $#cmd 0)
>+ msg = (NOTICE $cmd(1) : `{mshift $cmd})
>+ case /T
>+ msg = (TOPIC `{mshift $cmd})
>+ case /W
>+ msg = (WHOIS `{mshift $cmd})
>+ case /a
>+ msg = (AWAY : `{mshift $cmd})
>+ case /j
>+ if (~ $#cmd 2) {
>+ target=$cmd(2)
>+ title
>+ msg = (JOIN `{mshift $cmd})
>+ if(~ $target *,*)
>+ target = `{echo $target | awk -F',' '{print $NF}'}
>+ }
>+ case /l
>+ msg = (LIST `{mshift $cmd})
>+ case /m
>+ cmd = `{mshift $cmd}
>+ if (! ~ $#cmd 0) {
>+ to = $cmd(1)
> cmd = `{mshift $cmd}
>- if (! ~ $#cmd 0)
>- msg = (NOTICE $cmd(1) : `{mshift $cmd})
>- case /T
>- msg = (TOPIC `{mshift $cmd})
>- case /W
>- msg = (WHOIS `{mshift $cmd})
>- case /a
>- msg = (AWAY : `{mshift $cmd})
>- case /j
>- if (~ $#cmd 2) {
>- target=$cmd(2)
>- title
>- msg = (JOIN `{mshift $cmd})
>- if(~ $target *,*)
>- target = `{echo $target | awk -F',' '{print $NF}'}
>+ out = '('^$to^') ⇐ '^$"cmd
>+ msg = 'PRIVMSG '^$to^' :'^$"cmd
>+ }
>+ case /n
>+ nick = `{mshift $cmd}
>+ msg = (NICK $nick)
>+ case /p
>+ cmd = `{mshift $cmd}
>+ if (! ~ $#cmd 0)
>+ msg = (PART $cmd(1) : `{mshift $cmd})
>+ case /q
>+ msg = `{mshift $cmd}
>+ case /t
>+ target = `{mshift $cmd}
>+ title
>+ case /u
>+ msg = (USERS `{mshift $cmd})
>+ case /w
>+ msg = (WHO `{mshift $cmd})
>+ case /x
>+ echo QUIT : Leaving... > $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=$ifs
>+ ifs='
>+'
>+ msgs=`{echo -n $cmd | fmt -l $msglen}
>+ ifs=$ifs_orig
>+ for (cmd in $msgs) {
>+ if (~ $#msg 0 ) {
>+ msg=('PRIVMSG '^$target^' :'^$"cmd)
>+ out=('('^$target^') ⇐ '^$"cmd)
> }
>- case /l
>- msg = (LIST `{mshift $cmd})
>- case /m
>- cmd = `{mshift $cmd}
>- if (! ~ $#cmd 0) {
>- to = $cmd(1)
>- cmd = `{mshift $cmd}
>- out = '('^$to^') ⇐ '^$"cmd
>- msg = 'PRIVMSG '^$to^' :'^$"cmd
>+ if not {
>+ msg=($msg^'
>+PRIVMSG '^$target^' :'^$"cmd)
>+ out=($out^'
>+('^$target^') ⇐ '^$"cmd)
> }
>- case /n
>- nick = `{mshift $cmd}
>- msg = (NICK $nick)
>- case /p
>- cmd = `{mshift $cmd}
>- if (! ~ $#cmd 0)
>- msg = (PART $cmd(1) : `{mshift $cmd})
>- case /q
>- msg = `{mshift $cmd}
>- case /t
>- target = `{mshift $cmd}
>- title
>- case /u
>- msg = (USERS `{mshift $cmd})
>- case /w
>- msg = (WHO `{mshift $cmd})
>- case /x
>- echo QUIT : Leaving... > $netdir/data
>- exit
>- case /*
>- echo unknown command
>- case *
>- msg = 'PRIVMSG '^$target^' :'^$"cmd
>- out = '('^$target^') ⇐ '^$"cmd
> }
>- if (! ~ $#msg 0)
>- echo $msg > $netdir/data
>- if (! ~ $#out 0)
>- echo `{etime}^' '^$out
>+ msgs=()
>+ }
>+ if not {
>+ msg = 'PRIVMSG '^$target^' :'^$"cmd
>+ out = '('^$target^') ⇐ '^$"cmd
> }
> }
>
>@@ -211,10 +242,13 @@
> case -t
> target=$2
> shift
>+ case -l
>+ msglen=$2
>+ shift
> case -T
> tls=1
> case -*
>- echo 'usage: ircrc [-p port] [-P server password] [-r realname] [-t
>target] [-n nick] [-T] [server]' >[1=2]
>+ echo 'usage: ircrc [-p port] [-P server password] [-r realname] [-t
>target] [-n nick] [-l message format length] [-T] [server]' >[1=2]
> exit 'usage'
> }
> 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 @@
> .B -n
> .I nick
> ]
>+.B -l
>+.I message format length
>+]
> [
> .B -T
> ] [
>@@ -70,6 +73,10 @@
> Change the default nickname
> .RB ( $user ).
> .TP
>+.BI -l " length
>+Change the message formatting length, piping the messages sent through
>fmt with the given length. The maximum broken UTF code length is around
>510: messages may chopped if set higher.
>+.RB ( 100 ).
>+.TP
> .BI -T
> .br
> Use tls through
next prev parent reply other threads:[~2020-05-05 3:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-21 8:13 Romano
2020-05-05 3:08 ` Romano [this message]
2020-05-05 3:38 ` [9front] " ori
2020-05-05 7:43 ` Romano
2020-06-13 0:09 ` Romano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A5BFDE79-0CD5-4CD4-B1CE-332C2DB5FFE3@cpan.org \
--to=unobe@cpan.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).