From 080bf674e011a8d7205368fceeaab11fbc70c71b Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 19 Feb 2011 21:37:03 +0600 Subject: [PATCH] Add perl module perleval. It allows you to evaluate perl code you /msg to it. --- modules/perleval.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/perleval.pm diff --git a/modules/perleval.pm b/modules/perleval.pm new file mode 100644 index 00000000..ffba9ad8 --- /dev/null +++ b/modules/perleval.pm @@ -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