]> git.lizzy.rs Git - plan9front.git/blobdiff - rc/bin/ircrc
crop /lib/face/48x48x8/n/nixie.1 to the right size (was 512x512)
[plan9front.git] / rc / bin / ircrc
index e54d2a000b6a647b45dad1598a68fc38c4542da8..c746bb636383ec53933df9e725b987b5193c5193 100755 (executable)
@@ -34,13 +34,22 @@ fn work {
        echo NICK $nick > $netdir/data
        if (~ $#pass 1)
                echo PRIVMSG 'nickserv :'identify $"pass > $netdir/data
-       if(~ $#target 1){
+       if(! ~ $target ''){
                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 = ()
@@ -183,7 +199,7 @@ fn title {
                        echo name /$server/$target/-ircrc > /mnt/acme/$winid/ctl
        }
        if not
-               label ircrc $server - $target
+               label $target@$server
 }
 
 while (~ $1 -*) {
@@ -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 '\r\ 2' | pretty & 
+       cat $netdir/data | tr -d '\x2\xd\x1f' | pretty & 
        work
 }