]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[my_beep] modify flood protection
authorbw1 <redacted>
Sun, 8 Sep 2019 17:29:19 +0000 (19:29 +0200)
committerbw1 <redacted>
Sun, 8 Sep 2019 17:29:19 +0000 (19:29 +0200)
scripts/my_beep.pl

index c24534e31a8448090927622c172ed30754ee2d33..7723e7595e0b457a1cb2cfc5bf794848a50aa138 100644 (file)
@@ -14,7 +14,7 @@
 
 use strict;
 use vars qw($VERSION %IRSSI);
-$VERSION = "0.9";
+$VERSION = "0.10";
 %IRSSI = (
     authors    => "Remco den Breeje",
     contact    => "stacium or stek (most of the time) @ quakenet.org",
@@ -27,30 +27,30 @@ $VERSION = "0.9";
 use Irssi;
 
 my $can_I_beep = 1;
-my ($timeout_tag, $autoaway_to_tag);
+my ($timeout_tag);
 
 sub beep_overflow_timeout() {
        $can_I_beep = 1;
-       # and kill the loop
-        Irssi::timeout_remove($timeout_tag);
-        $autoaway_to_tag = undef;
 }
 
 sub my_beep() {
        my $beep_cmd = Irssi::settings_get_str("beep_cmd");
        if ($beep_cmd) {
                my $beep_flood = Irssi::settings_get_int('beep_flood');
-                # check on given beep_flood
-                if($beep_flood < 0)
-               {
+               # check on given beep_flood
+               if($beep_flood < 0) {
                        Irssi::print("Warning! Wrong value for beep_flood (time in milisecs)");
                        Irssi::signal_stop();
                        return;
                }
+               if (defined $timeout_tag) {
+                       Irssi::timeout_remove($timeout_tag);
+                       $timeout_tag= undef;
+               }
+               $timeout_tag = Irssi::timeout_add_once($beep_flood, 'beep_overflow_timeout', undef);
                if ($can_I_beep) {
-                       $timeout_tag = Irssi::timeout_add($beep_flood, 'beep_overflow_timeout', undef);
-                       system($beep_cmd);
                        $can_I_beep = 0;
+                       system($beep_cmd);
                }
                Irssi::signal_stop();
        }
git clone https://git.99rst.org/PROJECT