OSDN Git Service

ごく短時間に同一内容の連続POSTがきた場合は無視. au W63S (re) 対策. thanks to Takuo KITAME.
authormorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Thu, 17 Jul 2008 15:35:52 +0000 (15:35 +0000)
committermorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Thu, 17 Jul 2008 15:35:52 +0000 (15:35 +0000)
ChangeLog
keitairc
lib/Keitairc/IrcBuffer.pm
lib/plugins/00all
lib/plugins/00unread
lib/templates/all.html
lib/templates/unread.html

index 87eb826..130e922 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,7 @@
-Make HTML charset to variable $cf->web_charset
-Make irc charset to variable $cf->irc_charset
-Introduces use warnings, added undef checks, etc.
-Added filename/line info to plugins
+2008-07-18  Jun Morimoto  <morimoto@mrmt.net>
 
+       * \e$B$4$/C;;~4V$KF10lFbMF$NO"B3\e(BPOST\e$B$,$-$?>l9g$OL5;k\e(B.
+         au W63S (re) \e$BBP:v\e(B. thanks to Takuo KITAME.
 
 2008-06-29  Jun Morimoto  <morimoto@mrmt.net>
 
index d4ca232..c1f6ecf 100755 (executable)
--- a/keitairc
+++ b/keitairc
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # -*- mode: perl; coding: utf-8 -*-
 # keitairc
-# $Id: keitairc,v 1.59 2008-06-29 09:20:49 morimoto Exp $
+# $Id: keitairc,v 1.60 2008-07-17 15:35:52 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/keitairc,v $
 #
 # Copyright (c) 2003-2008 Jun Morimoto <morimoto@mrmt.net>
@@ -395,8 +395,13 @@ sub action_redirect_root{
 sub send_message{
        my $request = shift;
        my $channel = shift;
+       my $timestamp;
 
        my $message = $request->content();
+        if(length($message)){
+               ($message, $timestamp) = split(/&/, $message);
+               $timestamp =~ s/^stamp=//g; 
+        }
        $message =~ s/^m=//;
        $message =~ s/\+/ /g;
        $message = uri_unescape($message);
@@ -423,9 +428,11 @@ sub send_message{
                        }
                        $irc->yield(@postcmd);
                } elsif(length($channel)){
-                       $irc->yield(privmsg => $channel => $jis);
-                       my $cid = $ib->name2cid($channel);
-                       $ib->add_message($cid, $euc, $cf->irc_nick());
+                       if($ib->update_timestamp($timestamp)){
+                               $irc->yield(privmsg => $channel => $jis);
+                               my $cid = $ib->name2cid($channel);
+                               $ib->add_message($cid, $euc, $cf->irc_nick());
+                       }
                        $ib->message_added(1);
                }
        }
@@ -457,7 +464,6 @@ sub render_line{
                s/\s+/ /g;
                $buf .= "$_<br />";
        }
-       # Encode::from_to($buf, 'euc-jp', $cf->web_charset());
        return Encode::encode($cf->web_charset(), $buf);
 }
 
index 5ee8496..8ac6f55 100644 (file)
@@ -1,6 +1,6 @@
 # -*- mode: perl; coding: utf-8 -*-
 # Keitairc::IrcBuffer
-# $Id: IrcBuffer.pm,v 1.17 2008-06-29 12:04:50 morimoto Exp $
+# $Id: IrcBuffer.pm,v 1.18 2008-07-17 15:35:52 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/IrcBuffer.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -46,6 +46,9 @@ sub new{
        # chk
        $me->{message_added} = 0;
 
+       # timestamp of last posted message
+       $me->{timestamp} = 0;
+
         bless $me;
 }
 
@@ -347,4 +350,25 @@ sub colorize{
        $_;
 }
 
+################################################################
+# 同一秒間の連続発言を防ぐためのチェック。
+#
+# 前回 update_timestamp() が呼ばれた時刻と同じ時刻に
+# 再度 update_timestamp() が呼ばれたら 0 を返す。
+#
+# 前回 update_timestamp() が呼ばれた時刻と異なる時刻に
+# 再度 update_timestamp() が呼ばれたら 1 を返す。
+#
+sub update_timestamp{
+       my $me = shift;
+       my $time = time;
+
+       if($me->{timestamp} != $time){
+               $me->{timestamp} = $time;
+               return 1;
+       }
+
+       return 0;
+}
+
 1;
index 83e604b..e9e8710 100644 (file)
@@ -1,7 +1,7 @@
 # -*- mode: perl; coding: utf-8 -*-
 # keitairc/lib/plugins/00all
 # チャネルの全メッセージ閲覧
-# $Id: 00all,v 1.9 2008-06-29 09:20:49 morimoto Exp $
+# $Id: 00all,v 1.10 2008-07-17 15:35:52 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00all,v $
 
 # The line number (1 incremented) and filename below must be
@@ -34,6 +34,7 @@ $plugin = {
                        buf => $buf,
                        channel_compact => $cname,
                        cid => $cid,
+                       stamp => time,
                             });
        }
 };
index b0b7be7..25e0855 100644 (file)
@@ -1,7 +1,7 @@
 # -*- mode: perl; coding: utf-8 -*-
 # keitairc/lib/plugins/00unread
 # チャネルの未読メッセージ閲覧
-# $Id: 00unread,v 1.8 2008-06-29 09:20:49 morimoto Exp $
+# $Id: 00unread,v 1.9 2008-07-17 15:35:52 morimoto Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00unread,v $
 
 # The line number (1 incremented) and filename below must be
@@ -33,6 +33,7 @@ $plugin = {
                        buf => $buf,
                        channel_compact => $::ib->simple_escape(encode($::cf->web_charset(), $::ib->compact_channel_name($cid))),
                        cid => $cid,
+                       stamp => time,
                             });
        }
 };
index bca0dc0..eaad10e 100644 (file)
@@ -19,7 +19,8 @@
       <tmpl_else>
        <input type="text" name="m" />
       </tmpl_if>
-      <input type="submit" accesskey="1" value="[1] \94­\8c¾/\8dX\90V" /><br />
+      <input type="submit" accesskey="1" value="[1] \94­\8c¾/\8dX\90V" />
+      <input type="hidden" name="stamp" value="<!-- stamp -->" /><br />
     </form>
 
     <tmpl_if buf>
index 5e2e8d9..fd66af7 100644 (file)
@@ -20,7 +20,8 @@
       <tmpl_else>
        <input type="text" name="m" />
       </tmpl_if>
-      <input type="submit" accesskey="1" value="[1] \94­\8c¾/\8dX\90V" /><br />
+      <input type="submit" accesskey="1" value="[1] \94­\8c¾/\8dX\90V" />
+      <input type="hidden" name="stamp" value="<!-- stamp -->" /><br />
     </form>
 
     <tmpl_if buf>