mirror of
https://github.com/znc/znc.git
synced 2026-07-06 01:41:12 +02:00
Modperl's CreateTimer function now supports named arguments.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2138 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -329,9 +329,19 @@ sub NV {
|
||||
}
|
||||
|
||||
sub CreateTimer {
|
||||
my ($self, $job, $interval, $cycles, $description) = @_;
|
||||
my $self = shift;
|
||||
my $id = ZNC::Core::CreateUUID;
|
||||
my $ctimer = ZNC::CreatePerlTimer($self->{_cmod}, $interval, $cycles, "perl-timer-$id", $description, $id);
|
||||
my ($ctimer, $job);
|
||||
if (ref($_[0]) eq 'CODE') {
|
||||
# for those who doesn't want to use named args
|
||||
$job = shift;
|
||||
my ($interval, $cycles, $description) = @_;
|
||||
$ctimer = ZNC::CreatePerlTimer($self->{_cmod}, $interval, $cycles, "perl-timer-$id", $description, $id);
|
||||
} else {
|
||||
my %a = @_;
|
||||
$job = $a{task};
|
||||
$ctimer = ZNC::CreatePerlTimer($self->{_cmod}, $a{interval}//10, $a{cycles}//1, "perl-timer-$id", $a{description}//'Just Another Perl Timer', $id);
|
||||
}
|
||||
$self->{_ptimers}{$id}{job} = $job;
|
||||
$self->{_ptimers}{$id}{cobj} = $ctimer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user