]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[autolimit] change the config to irssi
authorbw1 <redacted>
Tue, 12 Feb 2019 19:48:07 +0000 (20:48 +0100)
committerbw1 <redacted>
Tue, 12 Feb 2019 19:48:07 +0000 (20:48 +0100)
scripts/autolimit.pl

index 7d25427a3b50e17745ecfea81b4f08657e60741a..d77666c29ad68ac6208ea2f589d653abbb429f54 100644 (file)
@@ -1,21 +1,33 @@
 use strict;
 use Irssi 20010920.0000 ();
 use vars qw($VERSION %IRSSI);
-$VERSION = "1.00";
+$VERSION = "1.01";
 %IRSSI = (
     authors     => 'David Leadbeater',
     contact     => 'dgl@dgl.cx',
     name        => 'autolimit',
-    description => 'does an autolimit for a channel, set variables in the script',
+    description => 'does an autolimit for a channel',
     license     => 'GNU GPLv2 or later',
     url         => 'http://irssi.dgl.cx/',
 );
 
-# Change these!
-my $channel = "#channel";
-my $offset = 5;
-my $tolerence = 2;
-my $time = 60;
+my $sname=$IRSSI{name};
+my $channel;
+my $offset;
+my $tolerence;
+my $time;
+my $timeouttag;
+
+sub sig_setup_changed {
+   $channel=Irssi::settings_get_str($sname.'_channel');
+   $offset=Irssi::settings_get_int($sname.'_offset');
+   $tolerence=Irssi::settings_get_int($sname.'_tolerence');
+   $time=Irssi::settings_get_int($sname.'_time');
+   if (defined $timeouttag) {
+      Irssi::timeout_remove($timeouttag);
+   }
+   $timeouttag = Irssi::timeout_add($time * 1000, 'checklimit','');
+}
 
 sub checklimit {
    my $c = Irssi::channel_find($channel);
@@ -29,5 +41,13 @@ sub checklimit {
    }
 }
 
-Irssi::timeout_add($time * 1000, 'checklimit','');
+Irssi::signal_add('setup changed', \&sig_setup_changed);
+
+Irssi::settings_add_str($sname, $sname.'_channel', "#channel");
+Irssi::settings_add_int($sname, $sname.'_offset', 5);
+Irssi::settings_add_int($sname, $sname.'_tolerence', 2);
+Irssi::settings_add_int($sname, $sname.'_time', 60);
+
+sig_setup_changed();
 
+# vim:set ts=3 sw=3 expandtab:
git clone https://git.99rst.org/PROJECT