]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[relm] bug fix
authorbw1 <redacted>
Mon, 25 Feb 2019 09:29:22 +0000 (10:29 +0100)
committerbw1 <redacted>
Mon, 25 Feb 2019 09:29:22 +0000 (10:29 +0100)
scripts/relm.pl

index e71eb59eb1ffc9a4f4548b9d70b8673097099a3e..460423ebc43b280a07e2a09fba965c43d85ef08b 100644 (file)
@@ -10,17 +10,17 @@ use strict;
 use Irssi;
 
 use vars qw($VERSION %IRSSI);
-$VERSION = "1.0";
+$VERSION = "1.1";
 %IRSSI = (
         authors         => "Maciek \'fahren\' Freudenheim",
         contact         => "fahren\@bochnia.pl",
         name            => "REdirect Last Message",
         description     => "Keeps last 15 messages in cache",
         license         => "GNU GPLv2 or later",
-        changed         => "Fri Mar 15 15:09:42 CET 2002"
+        changed         => "2019-02-25"
 );
 
-my %relm;
+my %relm=();
 
 sub cmd_relm {
        my ($args, $server, $winit) = @_;
@@ -29,13 +29,13 @@ sub cmd_relm {
        
        $where = $which unless $which =~ /[0-9]/;
 
-       $which = scalar(@{$relm{lc($ircnet)}}) unless ($which);
-
        unless ($relm{$ircnet}) {
                Irssi::print("%R>>%n Nothing in relm buffer on $ircnet.", MSGLEVEL_CRAP);
                return;
        }
 
+       $which = scalar(@{$relm{lc($ircnet)}}) unless ($which);
+
        if ($where eq "-l") {
                my $numspace;
                Irssi::print(">> ---- Context ------------------------", MSGLEVEL_CRAP);
@@ -83,7 +83,9 @@ sub event_privmsg {
 
        return if ($server->{nick} ne $target);
        my $relm = "\00312[ \00310$nick!$address \00312]\003 $text";
-       shift(@{$relm{$ircnet}}) if scalar(@{$relm{$ircnet}}) > 14;
+       if ( exists $relm{$ircnet} ) {
+               shift(@{$relm{$ircnet}}) if scalar(@{$relm{$ircnet}}) > 14;
+       }
        push(@{$relm{$ircnet}}, $relm);
 }
 
git clone https://git.99rst.org/PROJECT