]> git.vpit.fr Git - perl/scripts/xchat.git/blobdiff - Xchat/XPI/Events.pm
Fix Xchat::XPI::Events::{delay,filter} not passing the right arguments
[perl/scripts/xchat.git] / Xchat / XPI / Events.pm
index f387f8ae7e6bc6915caeeda9cf4ea70b1180cc44..d851caaeb961d04e705cd3753527ff4d627cd006 100644 (file)
@@ -5,30 +5,34 @@ use warnings;
 
 use Xchat qw<:all>;
 
-use lib get_info 'xchatdir';
-use Xchat::XPI;
-
-use constant {
- DEFAULT_DELAY => 1000
-};
+use constant DEFAULT_DELAY => 1000;
 
 our $VERSION = '0.04';
 
 sub _delay_cb {
  my ($cb, @args) = @{$_[0]};
+
  $cb->(@args);
+
  return REMOVE;
-};
+}
 
 sub delay {
- my $d = shift;
- $d = (defined $d) ? int $d : DEFAULT_DELAY;
- return hook_timer $d, \&_delay_cb, { data => \@_ };
+ my $delay = shift;
+
+ if (defined $delay) {
+  $delay = int $delay;
+ } else {
+  $delay = DEFAULT_DELAY;
+ }
+
+ hook_timer $delay, \&_delay_cb, { data => \@_ };
 }
 
 sub _filter_cb {
  my @args      = @{$_[0]};
  my ($cb, $to) = @{$_[1]};
+
  if ($cb->(@args)) {
   emit_print $to, @args;
   return EAT_ALL;
@@ -39,15 +43,16 @@ sub _filter_cb {
 
 sub filter {
  my $from = shift;
- return hook_print $from, \&_filter_cb, { data => \@_ };
+
+ hook_print $from, \&_filter_cb, { data => \@_ };
 }
 
 use base qw<Exporter>;
 
 our @EXPORT         = ();
 our %EXPORT_TAGS    = (
- 'funcs'  => [ qw<delay filter> ],
- 'consts' => [ qw<DEFAULT_DELAY> ]
+ 'funcs'  => [ qw<delay filter>  ],
+ 'consts' => [ qw<DEFAULT_DELAY> ],
 );
 our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
 $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];