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 >
Text File  |  1997-12-19  |  4KB  |  125 lines

  1. # <!-- -*- perl -*-
  2. # $Id: random.plm,v 2.6 1997/12/19 21:17:26 hasegawa Exp $
  3. # copyright (c)1997 pupu_j <hasegawa@agusa.nuie.nagoya-u.ac.jp>
  4.  
  5. package auto_random;
  6.  
  7. $_ = 'auto_random';
  8.  
  9. sub ss_privmsg {
  10.   local($serverno, $prefix, $cmd, $chan, $msg) = @_;
  11.   local($userno, $nick, $file, @list, $reply);
  12.   $userno = $'userno[$serverno];
  13.   $nick = &'prefix($prefix);
  14.   foreach $req (&'property($userno, 'request')) {
  15.     next unless $req eq $msg;
  16.     $file = &'expand(&'property($userno, 'file') || '');
  17.     if ($file && open(FILE, $file)) {
  18.       @list = <FILE>;
  19.       close(FILE);
  20.       $reply = $list[rand(scalar(@list))];
  21.       $reply =~ s/[\r\n]+//;
  22.       foreach $kanji (&'property($userno, 'kanji')) {
  23.         foreach $code (split(/\,/, $kanji)) {
  24.           if ("\L$code\E" eq 'euc') {
  25.             $reply = &'euc_jis($reply);
  26.           } elsif ("\L$code\E" eq 'jis') {
  27.             $reply = &'jis_jis($reply);
  28.           } elsif ("\L$code\E" eq 'sjis') {
  29.             $reply = &'sjis_jis($reply);
  30.           }
  31.         }
  32.       }
  33.     } else {
  34.       @list = &'property($userno, 'reply');
  35.       $reply = $list[rand(scalar(@list))];
  36.     }
  37.     if ($chan =~ /^[\#\&\+\-]/) {
  38.       &'s_print($serverno, '', 'PRIVMSG', $chan, $reply);
  39.     } else {
  40.       &'s_print($serverno, '', 'PRIVMSG', $nick, $reply);
  41.     }
  42.     foreach $cno (&'array($'clientlist)) {
  43.       next unless $'avail[$cno];
  44.       next unless $'userno[$cno] == $userno;
  45.       if ($chan =~ /^[\#\&\+\-]/) {
  46.         &'c_print($cno, &'user($cno), 'PRIVMSG', $chan, $reply);
  47.       } else {
  48.         &'c_print($cno, &'user($cno), 'PRIVMSG', $nick, $reply);
  49.       }
  50.     }
  51.     last;
  52.   }
  53.   return ($prefix, $cmd, $chan, $msg);
  54. }
  55.  
  56. __END__
  57. --><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  58. <HTML><HEAD><TITLE> auto/random.plm </TITLE></HEAD><BODY>
  59.  
  60. $B%*%s%i%$%s%I%-%e%a%s%H(B
  61.  
  62.  
  63. <HR><H3> $BL>A0(B </H3>
  64.  
  65. auto/random.plm - $BFCDj$NH/8@$KH?1~$7$F%i%s%@%`$JH/8@$r$9$k(B
  66.  
  67.  
  68. <HR><H3> $B@bL@(B </H3>
  69.  
  70. $BFCDj$N%a%C%;!<%8$,H/8@$5$l$k$H!";XDj$5$l$?%a%C%;!<%8$NCf$+$i(B
  71. $B$I$l$+(B1$B$D$r%i%s%@%`$KA*Br$7$FH/8@$7$^$9!#(B
  72.  
  73.  
  74. <HR><H3> $B%W%m%Q%F%#(B </H3>
  75.  
  76. <DL>
  77. <DT> auto.random.request* $B%a%C%;!<%8(B
  78. <DD>    $BH?1~$9$kH/8@$r;XDj$7$^$9!#(B
  79.         $B$3$3$G;XDj$7$?%a%C%;!<%8$N$I$l$+(B1$B$D$H0lCW$7$?>l9g$K(B
  80.         $B%i%s%@%`$KA*Br$5$l$?%a%C%;!<%8$rH/8@$7$^$9!#(B
  81. <DT> auto.random.reply* $B%a%C%;!<%8(B
  82. <DD>    $B%i%s%@%`$KH/8@$9$k%a%C%;!<%8$r;XDj$7$^$9!#(B
  83.         $B$3$NCf$N$I$l$+(B1$B$D$,%i%s%@%`$KA*Br$5$l$FH/8@$5$l$^$9!#(B
  84. <DT> auto.random.file $B%U%!%$%kL>(B
  85. <DD>    $B%i%s%@%`$KH/8@$9$k%a%C%;!<%8$N=q$+$l$?%U%!%$%k$r;XDj$7$^$9!#(B
  86.         $B%U%!%$%k$NCf$G$O(B1$B9T$K(B1$B$D$N%a%C%;!<%8$r=q$$$F2<$5$$!#(B
  87.         $B$3$N%W%m%Q%F%#$r;XDj$9$k$H!V(Bauto.random.reply$B!W$N;XDj$O(B
  88.         $BL58z$K$J$j$^$9!#(B
  89. <DT> auto.random.kanji* ({euc|jis|sjis})
  90. <DD>    $B%U%!%$%k$,$I$N4A;z%3!<%I$G=q$+$l$F$$$k$+$r;XDj$7$^$9!#(B
  91. </DL>
  92.  
  93.  
  94. <HR><H3> $B@_DjNc(B </H3>
  95.  
  96. <PRE>
  97. + auto/random.plm
  98. auto.random.request: $B$*$_$/$8(B
  99. auto.random.reply: $BBg5H$G$9(B
  100. auto.random.reply: $BCf5H$G$9(B
  101. auto.random.reply: $B>.5H$G$9(B
  102. auto.random.reply: $B5H$G$9(B
  103. auto.random.reply: $B6'$G$9(B
  104. auto.random.reply: $BBg6'$G$9(B
  105. </PRE>
  106.  
  107. $B!V$*$_$/$8!W$H$$$&H/8@$,$"$C$?$H$-$K!"!V(Bauto.random.reply$B!W$G(B
  108. $B;XDj$5$l$?%a%C%;!<%8$NCf$N$I$l$+(B1$B$D$rH/8@$7$^$9!#(B
  109.  
  110.  
  111. <PRE>
  112. + auto/random.plm
  113. auto.random.request: $B:#F|$N1?@*$O(B?
  114. auto.random.request: $B$&$i$J$$(B
  115. auto.random.file: fortune.txt
  116. auto.random.kanji: euc,jis
  117. auto.random.reply: $B$J$K$+$$$$$3$H$,$*$3$j$=$&$h!y(B
  118. </PRE>
  119.  
  120. $B!V:#F|$N1?@*$O(B?$B!W$+!V$&$i$J$$!W$N$I$A$i$+$NH/8@$,$"$C$?$H$-$K!"(B
  121. fortune.txt$B$NCf$K=q$+$l$?%a%C%;!<%8$NCf$N$I$l$+(B1$B$D$rH/8@$7$^$9!#(B
  122. $B$?$@$7$3$N$H$-!"(Bforture.txt$B$O(Beuc$B$+(Bjis$B$G=q$+$l$F$$$J$$$H$$$1$^$;$s!#(B
  123.  
  124. </BODY></HTML>
  125.