diff options
author | ppatience0 <ppatience0@gmail.com> | 2013-01-29 23:56:29 -0500 |
---|---|---|
committer | ppatience0 <ppatience0@gmail.com> | 2013-01-29 23:56:29 -0500 |
commit | f0a451d667da59780a2376e9b0f395e7c06a70a3 (patch) | |
tree | 119bd3103c8e9dc67cfd8c6f8bdd9d78308e9cb8 /rc/bin/ircrc | |
parent | bc0e5ffa2293526ed3cf65a025263d2599c1f331 (diff) | |
download | plan9front-f0a451d667da59780a2376e9b0f395e7c06a70a3.tar.xz |
Fixed some ircrc bugs. Only the last channel given to the -t flag is set as target. Unknown commands are not sent to the server. Control-D can be used to exit the client. When the connection is lost, an error message is displayed and the client waits for user input before exiting. Manual page updated.
Diffstat (limited to 'rc/bin/ircrc')
-rwxr-xr-x | rc/bin/ircrc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/rc/bin/ircrc b/rc/bin/ircrc index 9be2bc4e7..0a4a29196 100755 --- a/rc/bin/ircrc +++ b/rc/bin/ircrc @@ -38,9 +38,18 @@ fn work { title echo JOIN $target > $netdir/data } - while (cmd=`{read}) { - msg=() - out=() + if(~ $target *,*) + target = `{echo $target | awk -F',' '{print $NF}'} + while () { + cmd=`{read} + if(! ~ `{cat $netdir/status} *Established*) + exit + if(~ $#cmd 0) { + 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 @@ -61,6 +70,8 @@ fn work { target=$cmd(2) title msg = (JOIN `{mshift $cmd}) + if(~ $target *,*) + target = `{echo $target | awk -F',' '{print $NF}'} } case /l msg = (LIST `{mshift $cmd}) @@ -91,6 +102,8 @@ fn work { case /x echo QUIT : Leaving... > $netdir/data exit + case /* + echo unknown command case * msg = 'PRIVMSG '^$target^' :'^$"cmd out = '('^$target^') ⇐ '^$"cmd @@ -148,19 +161,22 @@ fn privmsg { s = s ":" $i; printf("%s\n", s); }' - } fn pretty { while (~ `{cat $netdir/status} *Established*) { - line=`{read} + if(! line=`{read}) { + echo Connection lost + date + exit + } switch ($line) { + case *PRIVMSG* + line = `{echo -n $line | privmsg} case *JOIN* *QUIT* *PART* *NICK* line = `{echo -n $line | misc} case *NOTICE* line = `{echo -n $line | notice} - case *PRIVMSG* - line = `{echo -n $line | privmsg} case *PING* echo -n $line | sed 's/PING/PONG/' > $netdir/data line = () @@ -235,6 +251,6 @@ if(~ $#userpass 2 && ~ $nick $user) { netdir=`{basename -d $clonefile} ^ / ^ `{cat /fd/4} echo connect $ip!$port >$netdir/ctl || exit 'cannot connect' echo connected to tcp!$ip!$port on $netdir - cat $netdir/data | tr -d '
' | pretty & + cat $netdir/data | tr -d '\x2\xd\x1f' | pretty & work } |