add ircrc
This commit is contained in:
parent
6c91d99ce2
commit
7ec0ad0990
4 changed files with 238 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
EST -18000 EDT -14400
|
||||
CST -21600 CDT -18000
|
||||
9943200 25664400 41392800 57718800 73447200 89168400
|
||||
104896800 120618000 126669600 152067600 162352800 183517200
|
||||
199245600 215571600 230695200 247021200 262749600 278470800
|
||||
|
|
236
rc/bin/ircrc
Executable file
236
rc/bin/ircrc
Executable file
|
@ -0,0 +1,236 @@
|
|||
#!/bin/rc
|
||||
|
||||
rfork ne
|
||||
|
||||
server=irc.freenode.net
|
||||
port=6667
|
||||
realname='<nil>'
|
||||
target=''
|
||||
clonefile=/net/tcp/clone
|
||||
netdir=()
|
||||
nick=$user
|
||||
pass=()
|
||||
|
||||
fn sighup {
|
||||
exit 'hang up'
|
||||
}
|
||||
|
||||
fn sigint sigterm {
|
||||
if (! ~ $#netdir 0)
|
||||
echo QUIT : Leaving... > $netdir/data
|
||||
}
|
||||
|
||||
fn mshift {
|
||||
shift
|
||||
echo $*
|
||||
}
|
||||
|
||||
fn etime {
|
||||
date | awk '{print $4}' | awk -F ':' '{print "[" $1 ":" $2 "]"}'
|
||||
}
|
||||
|
||||
fn work {
|
||||
echo USER $user foo bar :$realname > $netdir/data
|
||||
echo NICK $nick > $netdir/data
|
||||
if (~ $#pass 1)
|
||||
echo PRIVMSG 'nickserv :'identify $"pass > $netdir/data
|
||||
while (cmd=`{read}) {
|
||||
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})
|
||||
}
|
||||
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
|
||||
}
|
||||
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 *
|
||||
msg = 'PRIVMSG '^$target^' :'^$"cmd
|
||||
out = '('^$target^') ⇐ '^$"cmd
|
||||
}
|
||||
if (! ~ $#msg 0)
|
||||
echo $msg > $netdir/data
|
||||
if (! ~ $#out 0)
|
||||
echo `{etime}^' '^$out
|
||||
}
|
||||
}
|
||||
|
||||
fn misc {
|
||||
sed '
|
||||
s/^://
|
||||
s/!~?[a-zA-Z0-9_@\-|.{=\/:]+ /:/' |
|
||||
awk -F ':' '
|
||||
{
|
||||
s = $2 " «" $1 "»\t" $3;
|
||||
for(i = 4; i < NF+1; i++)
|
||||
s = s ":" $i;
|
||||
printf("%s\n", s);
|
||||
}'
|
||||
}
|
||||
|
||||
fn notice {
|
||||
sed '
|
||||
s/^NOTICE /:'^$server^':/
|
||||
s/^://
|
||||
s/!~?[a-zA-Z0-9_@\-|.{=\/]+ /:/' |
|
||||
awk -F ':' '
|
||||
{
|
||||
s = "-" $1 "- ⇒\t" $3;
|
||||
for(i = 4; i < NF+1; i++)
|
||||
s = s ":" $i;
|
||||
printf("%s\n", s);
|
||||
}'
|
||||
}
|
||||
|
||||
fn numeric {
|
||||
sed 's/^:[a-zA-Z0-9_@\-|.!=#]+ //
|
||||
s/ '^$nick^' //
|
||||
s/^353= /*** Users on /
|
||||
s/^[0-9][0-9][0-9] ?:?/*** /'
|
||||
}
|
||||
|
||||
fn privmsg {
|
||||
sed '
|
||||
s/^:/«/
|
||||
s/!~?[a-zA-Z0-9_@\-|.{=\/:]+ PRIVMSG /» ⇒ :/
|
||||
s/#[a-zA-Z0-9_@\-|.#]+/(&)/' |
|
||||
awk -F ':' '
|
||||
{
|
||||
s = $2 $1 $3;
|
||||
for(i = 4; i < NF+1; i++)
|
||||
s = s ":" $i;
|
||||
printf("%s\n", s);
|
||||
}'
|
||||
|
||||
}
|
||||
|
||||
fn pretty {
|
||||
while (~ `{cat $netdir/status} Established*) {
|
||||
line=`{read}
|
||||
switch ($line) {
|
||||
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 = ()
|
||||
case *
|
||||
line = `{echo -n $line | numeric}
|
||||
}
|
||||
if (! ~ $#line 0)
|
||||
echo `{etime} $line
|
||||
}
|
||||
exit
|
||||
}
|
||||
|
||||
fn getip {
|
||||
echo $1 ip | ndb/dnsquery | sed 1q | awk '{print $NF}'
|
||||
}
|
||||
|
||||
fn title {
|
||||
if (! ~ $#winid 0) {
|
||||
if (test -f /mnt/acme/$winid/ctl)
|
||||
echo name /$server/$target/-ircrc > /mnt/acme/$winid/ctl
|
||||
}
|
||||
if not
|
||||
label ircrc $server - $target
|
||||
}
|
||||
|
||||
while (~ $1 -*) {
|
||||
switch ($1) {
|
||||
case -n
|
||||
nick=$2
|
||||
shift
|
||||
case -p
|
||||
port=$2
|
||||
shift
|
||||
case -r
|
||||
realname=$2
|
||||
shift
|
||||
case -t
|
||||
target=$2
|
||||
shift
|
||||
case -*
|
||||
echo 'usage: ircrc [-p port] [-r realname] [-t target] [-n nick] [server]' >[1=2]
|
||||
exit 'usage'
|
||||
}
|
||||
shift
|
||||
}
|
||||
|
||||
if (~ $#* 1) {
|
||||
switch ($1) {
|
||||
case bitlbee
|
||||
server=im.bitlbee.org
|
||||
case oftc
|
||||
server=irc.oftc.net
|
||||
case *
|
||||
server=$1
|
||||
}
|
||||
}
|
||||
|
||||
ip=`{getip $server}
|
||||
if (~ $#ip 0) {
|
||||
echo cant translate $server
|
||||
exit 'unknown host'
|
||||
}
|
||||
|
||||
title
|
||||
userpass=`{auth/userpasswd 'server='^$server^' service=irc user='^$nick >[2]/dev/null}
|
||||
if(~ $#userpass 2 && ~ $nick $user) {
|
||||
nick=$userpass(1)
|
||||
pass=$userpass(2)
|
||||
}
|
||||
|
||||
<[4] $clonefile {
|
||||
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 &
|
||||
work
|
||||
}
|
|
@ -4601,3 +4601,4 @@ The goal should be a Plan 9 "distro" that runs natively on AMD-64, and can open
|
|||
I was using "startx" in the figurative sense.
|
||||
Google Search provides at least 22 special features beyond the original word-search capability.
|
||||
Are you sure you're on the right website?
|
||||
(#go-nuts) <areece> The mailing list feels more hostile than the IRC :-/
|
||||
|
|
0
sys/src/cmd/tcs/charsets.awk
Normal file → Executable file
0
sys/src/cmd/tcs/charsets.awk
Normal file → Executable file
Loading…
Reference in a new issue