Skip to content
Browse files

Avoid sending more than one notification per window and per second

  • Loading branch information...
1 parent 5eb67a6 commit a965e743a7cdc34f79d7e94c7df28a26a08279ae @rgs committed May 18, 2010
Showing with 15 additions and 2 deletions.
  1. +15 −2 griwlrssi.pl
View
17 griwlrssi.pl
@@ -19,14 +19,27 @@ sub send_to_growl {
}
}
+# This is to avoid sending more than one
+# notification per "window" and per second
+my %last_notification_time;
+
Irssi::signal_add_last('message private', sub {
my (undef, $data, $nick) = @_;
- send_to_growl("<$nick>", $data);
+ my $t = time;
+ if (($last_notification_time{$nick} || 0) != $t) {
+ send_to_growl("<$nick>", $data);
+ $last_notification_time{$nick} = $t;
+ }
});
Irssi::signal_add_last('print text', sub {
my ($dest, undef, $stripped) = @_;
if ($dest->{level} & MSGLEVEL_HILIGHT) {
- send_to_growl($dest->{target}, $stripped);
+ my $t = time;
+ my $targ = $dest->{target};
+ if (($last_notification_time{$targ} || 0) != $t) {
+ send_to_growl($targ, $stripped);
+ $last_notification_time{$targ} = $t;
+ }
}
});

0 comments on commit a965e74

Please sign in to comment.
Something went wrong with that request. Please try again.