mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Add perl module perleval.
It allows you to evaluate perl code you /msg to it.
This commit is contained in:
31
modules/perleval.pm
Normal file
31
modules/perleval.pm
Normal 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
|
||||
Reference in New Issue
Block a user