This commit is contained in:
cinap_lenrek 2013-01-30 06:30:07 +01:00
commit 8e658df4fe
2 changed files with 53 additions and 30 deletions

View file

@ -38,9 +38,18 @@ fn work {
title title
echo JOIN $target > $netdir/data echo JOIN $target > $netdir/data
} }
while (cmd=`{read}) { if(~ $target *,*)
msg=() target = `{echo $target | awk -F',' '{print $NF}'}
out=() while () {
cmd=`{read}
if(! ~ `{cat $netdir/status} *Established*)
exit
if(~ $#cmd 0) {
echo QUIT : Leaving... > $netdir/data
exit
}
msg=()
out=()
switch ($cmd(1)) { switch ($cmd(1)) {
case /! case /!
eval `{mshift $cmd} | while(rc=`{read})echo 'PRIVMSG '^$target^' :' $rc | tee $netdir/data eval `{mshift $cmd} | while(rc=`{read})echo 'PRIVMSG '^$target^' :' $rc | tee $netdir/data
@ -61,6 +70,8 @@ fn work {
target=$cmd(2) target=$cmd(2)
title title
msg = (JOIN `{mshift $cmd}) msg = (JOIN `{mshift $cmd})
if(~ $target *,*)
target = `{echo $target | awk -F',' '{print $NF}'}
} }
case /l case /l
msg = (LIST `{mshift $cmd}) msg = (LIST `{mshift $cmd})
@ -91,6 +102,8 @@ fn work {
case /x case /x
echo QUIT : Leaving... > $netdir/data echo QUIT : Leaving... > $netdir/data
exit exit
case /*
echo unknown command
case * case *
msg = 'PRIVMSG '^$target^' :'^$"cmd msg = 'PRIVMSG '^$target^' :'^$"cmd
out = '('^$target^') ⇐ '^$"cmd out = '('^$target^') ⇐ '^$"cmd
@ -148,19 +161,22 @@ fn privmsg {
s = s ":" $i; s = s ":" $i;
printf("%s\n", s); printf("%s\n", s);
}' }'
} }
fn pretty { fn pretty {
while (~ `{cat $netdir/status} *Established*) { while (~ `{cat $netdir/status} *Established*) {
line=`{read} if(! line=`{read}) {
echo Connection lost
date
exit
}
switch ($line) { switch ($line) {
case *PRIVMSG*
line = `{echo -n $line | privmsg}
case *JOIN* *QUIT* *PART* *NICK* case *JOIN* *QUIT* *PART* *NICK*
line = `{echo -n $line | misc} line = `{echo -n $line | misc}
case *NOTICE* case *NOTICE*
line = `{echo -n $line | notice} line = `{echo -n $line | notice}
case *PRIVMSG*
line = `{echo -n $line | privmsg}
case *PING* case *PING*
echo -n $line | sed 's/PING/PONG/' > $netdir/data echo -n $line | sed 's/PING/PONG/' > $netdir/data
line = () line = ()
@ -235,6 +251,6 @@ if(~ $#userpass 2 && ~ $nick $user) {
netdir=`{basename -d $clonefile} ^ / ^ `{cat /fd/4} netdir=`{basename -d $clonefile} ^ / ^ `{cat /fd/4}
echo connect $ip!$port >$netdir/ctl || exit 'cannot connect' echo connect $ip!$port >$netdir/ctl || exit 'cannot connect'
echo connected to tcp!$ip!$port on $netdir echo connected to tcp!$ip!$port on $netdir
cat $netdir/data | tr -d ' ' | pretty & cat $netdir/data | tr -d '\x2\xd\x1f' | pretty &
work work
} }

View file

@ -25,15 +25,15 @@ ircrc \- internet relay chat client
.SH DESCRIPTION .SH DESCRIPTION
.I Ircrc .I Ircrc
is an IRC client. is an IRC client.
Messages are sent from stdin and received from stdout. Messages are sent from standard input and
received from standard output.
The default server is The default server is
.BR irc.freenode.net . .BR irc.freenode.net .
.I Ircrc The arguments
expands
.B bitlbee .B bitlbee
and and
.B oftc .B oftc
to are expanded to
.B im.bitlbee.org .B im.bitlbee.org
and and
.BR irc.oftc.net , .BR irc.oftc.net ,
@ -49,15 +49,23 @@ Change the default name
.RB ( <nil> ). .RB ( <nil> ).
.TP .TP
.BI -t " target .BI -t " target
Set and join the target channel Set and join the target channel.
(multiple channels may be separated by commas). If multiple channels are specified,
only the last one will be set as
.IR target .
Messages are sent to
.I target
unless they are commands.
.TP .TP
.BI -n " nick .BI -n " nick
Change the default nickname Change the default nickname
.RB ( $user ). .RB ( $user ).
.SS Commands .SS Commands
.I Ircrc .I Ircrc
understands the following commands: commands begin with a slash.
Unrecognized commands result in an error message
and send nothing to the server.
The commands are:
.TP .TP
.BI /! " cmd .BI /! " cmd
Send the output of the shell command Send the output of the shell command
@ -110,11 +118,11 @@ Send the raw IRC command
to the server. to the server.
.TP .TP
.BI /t " target .BI /t " target
Set the current target. Set
Messages are sent to .IR target .
If
.I target .I target
unless they are commands. is more than one channel,
If the current target is more than one channel,
any messages are sent to all of them. any messages are sent to all of them.
.TP .TP
.B /u .B /u
@ -128,8 +136,8 @@ command.
.B /x .B /x
.B QUIT .B QUIT
command. command.
Control-D also sends this command.
.PP .PP
Anything else is sent as a message to the current target.
See RFC 1459 and RFC 2812 for detailed information about See RFC 1459 and RFC 2812 for detailed information about
IRC commands. IRC commands.
.SH EXAMPLES .SH EXAMPLES
@ -147,9 +155,7 @@ as a different user:
% ircrc -r glenda -n glenda irc.oftc.net % ircrc -r glenda -n glenda irc.oftc.net
.EE .EE
.PP .PP
Join two channels on login Join two channels on login:
(remember to set the target to a single channel,
otherwise messages are sent to both):
.IP .IP
.EX .EX
% ircrc -t '#cat-v,#plan9' % ircrc -t '#cat-v,#plan9'
@ -162,12 +168,13 @@ otherwise messages are sent to both):
.B http://tools.ietf.org/html/rfc2812 .B http://tools.ietf.org/html/rfc2812
.SH BUGS .SH BUGS
.PP .PP
.I Ircrc .I Auth/userpasswd
calls the inexistent (which is called by
.IR auth/userpasswd . .IR ircrc )
.PP isn't compiled by default.
Some of
.BR irc.freenode.net 's
welcome messages contain control characters.
.PP .PP
Some fonts do not support the nickname delimiters. Some fonts do not support the nickname delimiters.
.PP
If the connection is lost,
.I ircrc
waits for input before exiting.