| 1 |
root |
1.1 |
#! perl |
| 2 |
|
|
|
| 3 |
|
|
# generic perl code evaluator |
| 4 |
|
|
|
| 5 |
root |
1.2 |
sub eval_event { |
| 6 |
|
|
my ($event, $args, @args) = @_; |
| 7 |
|
|
|
| 8 |
|
|
my $code = $event->message; |
| 9 |
|
|
my $who = eval { $event->environment->name } || "<unknown>"; |
| 10 |
|
|
|
| 11 |
|
|
my $rv = eval "my ($args) = \@args;\n" |
| 12 |
|
|
. "#line 1 \"$who\"\n" |
| 13 |
|
|
. $code; |
| 14 |
|
|
|
| 15 |
|
|
warn $@ if $@; |
| 16 |
|
|
|
| 17 |
|
|
$rv |
| 18 |
|
|
} |
| 19 |
|
|
|
| 20 |
root |
1.1 |
# currently say only |
| 21 |
|
|
sub on_say { |
| 22 |
|
|
my ($event) = @_; |
| 23 |
elmex |
1.3 |
my ($event, $ob, $who, $msg, $options) = @$event{qw(event who activator message options)}; |
| 24 |
root |
1.1 |
|
| 25 |
|
|
local $_ = $msg; |
| 26 |
root |
1.2 |
|
| 27 |
elmex |
1.3 |
eval_event $event, '$ob, $who, $msg, $options', $ob, $who, $msg, $options |
| 28 |
root |
1.1 |
} |