From: bw1 Date: Tue, 12 Feb 2019 19:48:07 +0000 (+0100) Subject: [autolimit] change the config to irssi X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=481491aab11afb00f8862c4cadd963861d4c870b;p=irssi-scripts.irssi.org.git [autolimit] change the config to irssi --- diff --git a/scripts/autolimit.pl b/scripts/autolimit.pl index 7d25427..d77666c 100644 --- a/scripts/autolimit.pl +++ b/scripts/autolimit.pl @@ -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: