home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
2.x
/
plum2_15_2.lzh
/
module
/
auto
/
random.plm
< prev
next >
Wrap
Text File
|
1997-12-19
|
4KB
|
125 lines
# <!-- -*- perl -*-
# $Id: random.plm,v 2.6 1997/12/19 21:17:26 hasegawa Exp $
# copyright (c)1997 pupu_j <hasegawa@agusa.nuie.nagoya-u.ac.jp>
package auto_random;
$_ = 'auto_random';
sub ss_privmsg {
local($serverno, $prefix, $cmd, $chan, $msg) = @_;
local($userno, $nick, $file, @list, $reply);
$userno = $'userno[$serverno];
$nick = &'prefix($prefix);
foreach $req (&'property($userno, 'request')) {
next unless $req eq $msg;
$file = &'expand(&'property($userno, 'file') || '');
if ($file && open(FILE, $file)) {
@list = <FILE>;
close(FILE);
$reply = $list[rand(scalar(@list))];
$reply =~ s/[\r\n]+//;
foreach $kanji (&'property($userno, 'kanji')) {
foreach $code (split(/\,/, $kanji)) {
if ("\L$code\E" eq 'euc') {
$reply = &'euc_jis($reply);
} elsif ("\L$code\E" eq 'jis') {
$reply = &'jis_jis($reply);
} elsif ("\L$code\E" eq 'sjis') {
$reply = &'sjis_jis($reply);
}
}
}
} else {
@list = &'property($userno, 'reply');
$reply = $list[rand(scalar(@list))];
}
if ($chan =~ /^[\#\&\+\-]/) {
&'s_print($serverno, '', 'PRIVMSG', $chan, $reply);
} else {
&'s_print($serverno, '', 'PRIVMSG', $nick, $reply);
}
foreach $cno (&'array($'clientlist)) {
next unless $'avail[$cno];
next unless $'userno[$cno] == $userno;
if ($chan =~ /^[\#\&\+\-]/) {
&'c_print($cno, &'user($cno), 'PRIVMSG', $chan, $reply);
} else {
&'c_print($cno, &'user($cno), 'PRIVMSG', $nick, $reply);
}
}
last;
}
return ($prefix, $cmd, $chan, $msg);
}
__END__
--><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE> auto/random.plm </TITLE></HEAD><BODY>
$B%*%s%i%$%s%I%-%e%a%s%H(B
<HR><H3> $BL>A0(B </H3>
auto/random.plm - $BFCDj$NH/8@$KH?1~$7$F%i%s%@%`$JH/8@$r$9$k(B
<HR><H3> $B@bL@(B </H3>
$BFCDj$N%a%C%;!<%8$,H/8@$5$l$k$H!";XDj$5$l$?%a%C%;!<%8$NCf$+$i(B
$B$I$l$+(B1$B$D$r%i%s%@%`$KA*Br$7$FH/8@$7$^$9!#(B
<HR><H3> $B%W%m%Q%F%#(B </H3>
<DL>
<DT> auto.random.request* $B%a%C%;!<%8(B
<DD> $BH?1~$9$kH/8@$r;XDj$7$^$9!#(B
$B$3$3$G;XDj$7$?%a%C%;!<%8$N$I$l$+(B1$B$D$H0lCW$7$?>l9g$K(B
$B%i%s%@%`$KA*Br$5$l$?%a%C%;!<%8$rH/8@$7$^$9!#(B
<DT> auto.random.reply* $B%a%C%;!<%8(B
<DD> $B%i%s%@%`$KH/8@$9$k%a%C%;!<%8$r;XDj$7$^$9!#(B
$B$3$NCf$N$I$l$+(B1$B$D$,%i%s%@%`$KA*Br$5$l$FH/8@$5$l$^$9!#(B
<DT> auto.random.file $B%U%!%$%kL>(B
<DD> $B%i%s%@%`$KH/8@$9$k%a%C%;!<%8$N=q$+$l$?%U%!%$%k$r;XDj$7$^$9!#(B
$B%U%!%$%k$NCf$G$O(B1$B9T$K(B1$B$D$N%a%C%;!<%8$r=q$$$F2<$5$$!#(B
$B$3$N%W%m%Q%F%#$r;XDj$9$k$H!V(Bauto.random.reply$B!W$N;XDj$O(B
$BL58z$K$J$j$^$9!#(B
<DT> auto.random.kanji* ({euc|jis|sjis})
<DD> $B%U%!%$%k$,$I$N4A;z%3!<%I$G=q$+$l$F$$$k$+$r;XDj$7$^$9!#(B
</DL>
<HR><H3> $B@_DjNc(B </H3>
<PRE>
+ auto/random.plm
auto.random.request: $B$*$_$/$8(B
auto.random.reply: $BBg5H$G$9(B
auto.random.reply: $BCf5H$G$9(B
auto.random.reply: $B>.5H$G$9(B
auto.random.reply: $B5H$G$9(B
auto.random.reply: $B6'$G$9(B
auto.random.reply: $BBg6'$G$9(B
</PRE>
$B!V$*$_$/$8!W$H$$$&H/8@$,$"$C$?$H$-$K!"!V(Bauto.random.reply$B!W$G(B
$B;XDj$5$l$?%a%C%;!<%8$NCf$N$I$l$+(B1$B$D$rH/8@$7$^$9!#(B
<PRE>
+ auto/random.plm
auto.random.request: $B:#F|$N1?@*$O(B?
auto.random.request: $B$&$i$J$$(B
auto.random.file: fortune.txt
auto.random.kanji: euc,jis
auto.random.reply: $B$J$K$+$$$$$3$H$,$*$3$j$=$&$h!y(B
</PRE>
$B!V:#F|$N1?@*$O(B?$B!W$+!V$&$i$J$$!W$N$I$A$i$+$NH/8@$,$"$C$?$H$-$K!"(B
fortune.txt$B$NCf$K=q$+$l$?%a%C%;!<%8$NCf$N$I$l$+(B1$B$D$rH/8@$7$^$9!#(B
$B$?$@$7$3$N$H$-!"(Bforture.txt$B$O(Beuc$B$+(Bjis$B$G=q$+$l$F$$$J$$$H$$$1$^$;$s!#(B
</BODY></HTML>