From e0ad8bd911871f9cab6e230fada3462bf6565651 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Fri, 21 Jan 2011 17:44:27 -0700 Subject: [PATCH] Added an optional @args onto event_run() for sending @args to the subs that have hooked onto the event. --- doc/CHANGELOG | 2 ++ src/API/Std.pm | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 2a77b84..ef0193c 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev ================================================================== + * Added an optional @args onto event_run() for sending @args + to the subs that have hooked onto the event. * Parse the channels the bot is in. * Parse Numeric:438. * Added timer_add() and timer_del() to API::Std for timers. diff --git a/src/API/Std.pm b/src/API/Std.pm index 013bdbf..90c01b7 100644 --- a/src/API/Std.pm +++ b/src/API/Std.pm @@ -135,11 +135,16 @@ sub event_del # Trigger an event. sub event_run { - my ($event) = @_; + my ($event, @args) = @_; if (defined $EVENTS{lc($event)} and defined $HOOKS{lc($event)}) { foreach my $hk (keys %{ $HOOKS{lc($event)} }) { - &{ $HOOKS{lc($event)}{$hk} }(); + if (defined @args) { + &{ $HOOKS{lc($event)}{$hk} }(@args); + } + else { + &{ $HOOKS{lc($event)}{$hk} }(); + } } }