Permalink
Browse files

camptail: refactor make_callback to be generally useful

As we introduce new types of callback, we can reuse this
code.
  • Loading branch information...
peff committed Apr 1, 2011
1 parent 6255e8c commit cc660accb41df5562627cd3c225e5bdcd02b0f97
Showing with 9 additions and 3 deletions.
  1. +9 −3 camptail.pl
View
@@ -113,18 +113,24 @@ sub read_rcfile {
}
}
sub setup_callback {
my (undef, $code) = @_;
sub make_callback {
my $code = shift;
if ($code =~ /^[A-za-z0-9_]+$/) {
$code .= '(@_)';
}
$callback = eval <<EOF;
my $sub = eval <<EOF;
sub {
my (\$message, \$room) = \@_;
$code
}
EOF
$@ and die $@;
return $sub;
}
sub setup_callback {
my (undef, $code) = @_;
$callback = make_callback($code);
}
{

0 comments on commit cc660ac

Please sign in to comment.