Add perl module perleval.

It allows you to evaluate perl code you /msg to it.
This commit is contained in:
Alexey Sokolov
2011-02-19 21:37:03 +06:00
parent 92304835ef
commit 080bf674e0

31
modules/perleval.pm Normal file
View File

@@ -0,0 +1,31 @@
use strict;
use warnings;
package perleval;
use base 'ZNC::Module';
sub description {
'Evaluates perl code'
}
sub OnLoad {
my $self = shift;
if (!$self->GetUser->IsAdmin) {
$_[1] = 'Only admin can load this module';
return 0
}
return 1
}
sub OnModCommand {
my $self = shift;
my $cmd = shift;
my $x = eval $cmd;
if ($@) {
$self->PutModule("Error: $@")
} else {
$self->PutModule("Result: $x")
}
}
1