home *** CD-ROM | disk | FTP | other *** search
/ ftp.madoka.org / 2014.12.ftp.madoka.org.tar / ftp.madoka.org / pub / plum / plum2_33_1.lzh / module / auto / cache.plm < prev    next >
Text File  |  1999-03-24  |  4KB  |  133 lines

  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- $_ if 0; # -*- perl -*-
  2. # $Id: cache.plm,v 2.5 1999/01/31 10:07:05 hasegawa Exp $
  3. # copyright (c)1999 Yoshinori Hasegawa <hasegawa@madoka.org>
  4.  
  5. package auto_cache;
  6.  
  7. $SIZE = 10;
  8. $EXPIRE = 600;
  9.  
  10. $_ = 'auto_cache';
  11.  
  12. sub module_disable {
  13.   local($userno) = @_;
  14.   local($no, $chan);
  15.   foreach $key (keys(%cache)) {
  16.     ($no, $chan) = split(/$;/, $key, 2);
  17.     next unless $'userno[$no] == $userno;
  18.     delete $cache{$key};
  19.   }
  20. }
  21.  
  22. sub server_close {
  23.   local($serverno) = @_;
  24.   local($no, $chan);
  25.   foreach $key (keys(%cache)) {
  26.     ($no, $chan) = split(/$;/, $key, 2);
  27.     next unless $no == $serverno;
  28.     delete $cache{$key};
  29.   }
  30. }
  31.  
  32. sub ss_privmsg {
  33.   local($serverno, $prefix, $cmd, @params) = @_;
  34.   local($regex);
  35.   if (&'channel($params[0])) {
  36.     foreach $clear (&'property($'userno[$serverno], 'clear')) {
  37.       $regex = &'regex(&'jis_euc($clear));
  38.       next unless &'jis_euc($params[1]) =~ /$regex/;
  39.       $cache{$serverno, $params[0]} = '';
  40.       last;
  41.     }
  42.   }
  43.   return ($prefix, $cmd, @params);
  44. }
  45.  
  46. sub sp_privmsg {
  47.   local($serverno, $prefix, $cmd, @params) = @_;
  48.   local(@list, $size, $key, $expire, $now, $time, $text);
  49.   if (&'channel($params[0])) {
  50.     $size = &'property($'userno[$serverno], 'size');
  51.     $size = $SIZE unless defined($size);
  52.     $key = $serverno . $; . $params[0];
  53.     @list = &'array($cache{$key});
  54.     while (@list > $size) {
  55.       shift(@list);
  56.     }
  57.     $expire = &'property($'userno[$serverno], 'expire');
  58.     $expire = $EXPIRE unless defined($expire);
  59.     $now = time();
  60.     foreach $line (@list) {
  61.       ($time, $text) = split(/\:/, $line, 2);
  62.       next if ($expire != 0 && $time + $expire < $now);
  63.       return () if $text eq $params[1];
  64.     }
  65.     $cache{$key} = '' unless $cache{$key};
  66.     $cache{$key} .= &'list($now . ':' . $params[1]);
  67.   }
  68.   return ($prefix, $cmd, @params);
  69. }
  70.  
  71. sub ss_part {
  72.   local($serverno, $prefix, $cmd, @params) = @_;
  73.   delete $cache{$serverno, $params[0]};
  74.   return ($prefix, $cmd, @params);
  75. }
  76.  
  77. __END__
  78. --><HTML><HEAD>
  79. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-2022-JP">
  80. <LINK REV="made" HREF="mailto:hasegawa@madoka.org">
  81. <TITLE>auto/cache.plm</TITLE></HEAD><BODY>
  82.  
  83. $B%*%s%i%$%s%I%-%e%a%s%H(B
  84.  
  85.  
  86. <HR><H3>$BL>A0(B</H3>
  87.  
  88. auto/cache.plm - $BF1$8H/8@$r7+$jJV$5$J$$$h$&$K@)8B$9$k(B
  89.  
  90.  
  91. <HR><H3>$B@bL@(B</H3>
  92.  
  93. $B2a5n$KH/8@$7$?J8;zNs$rJ]B8$7$F$*$-!"$=$NCf$KH/8@$7$h$&$H$7$F$$$k(B
  94. $BJ8;zNs$,$"$l$P!"$=$l$rH/8@$7$J$$$h$&$K$7$^$9!#(B
  95.  
  96.  
  97. <HR><H3>$B%W%m%Q%F%#(B</H3>
  98.  
  99. <DL>
  100. <DT>  auto.cache.size $B%-%c%C%7%e$NBg$-$5(B
  101. </DT>
  102. <DD>    $BJ]B8$7$F$*$/H/8@?t$N?t$r;XDj$7$^$9!#(B
  103.         $B%G%U%)%k%H$G$O(B10$B$K$J$C$F$$$^$9!#(B
  104. </DD>
  105. <DT>  auto.cache.expire $B%-%c%C%7%e$NM-8z4|8B(B
  106. </DT>
  107. <DD>    $B%-%c%C%7%e$,M-8z$J;~4V$r;XDj$7$^$9!#(B
  108.         $B$3$3$G;XDj$7$?IC?t$,7P2a$7$?%-%c%C%7%e$O<+F0E*$K%/%j%"$5$l$^$9!#(B
  109.         0$B$r;XDj$9$k$H!"%/%j%"$O9T$o$l$^$;$s!#(B
  110.         $B%G%U%)%k%H$G$O(B600$B$K$J$C$F$$$^$9!#(B
  111. </DD>
  112. <DT>  auto.cache.clear* $B%-%c%C%7%e$r%/%j%"$9$kH/8@(B
  113. </DT>
  114. <DD>    $B$3$3$G;XDj$7$?J8;zNs$rH/8@$9$k$H!"%-%c%C%7%e$r%/%j%"$7$^$9!#(B
  115. </DD>
  116. </DL>
  117.  
  118.  
  119. <HR><H3>$B@_DjNc(B</H3>
  120.  
  121. <PRE>
  122. + auto/cache.plm
  123. auto.cache.size: 5
  124. auto.cache.expire: 300
  125. auto.cache.clear: $B$W$i$`$7$g$-$+(B
  126. </PRE>
  127.  
  128. $B2a5n$NH/8@$r(B5$B$D$^$GJ]B8$7$F$*$-!"$=$l$HF1$8H/8@$r$7$J$$$h$&$K$7$^$9!#(B
  129. $B!V$W$i$`$7$g$-$+!W$HH/8@$9$k$H!"$=$N%A%c%s%M%k$N%-%c%C%7%e$r%/%j%"$7$^$9!#(B
  130. $B$^$?!"(B300$BIC$,7P2a$7$?%-%c%C%7%e$b<+F0E*$K%/%j%"$5$l$^$9!#(B
  131.  
  132. </BODY></HTML>
  133.