Permalink
Browse files

Add perl module perleval.

It allows you to evaluate perl code you /msg to it.
  • Loading branch information...
1 parent 9230483 commit 080bf674e011a8d7205368fceeaab11fbc70c71b Alexey Sokolov committed Feb 19, 2011
Showing with 31 additions and 0 deletions.
  1. +31 −0 modules/perleval.pm
View
@@ -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

0 comments on commit 080bf67

Please sign in to comment.