Permalink
Browse files

camptail: automagically pass arguments to callback functions

A callback like "foo" is pointless. It will call the foo
function, but not pass any arguments, so the result can't
have any information about the message or room we are
processing. Instead, let's convert it into "foo(@_)".

This means you can define some pre-made callbacks in your rc
file, and then use them like "camptail --callback=foo".
  • Loading branch information...
peff committed Mar 28, 2011
1 parent a04f0d8 commit 4a7d9bcc61a66c56f8cf3a143bcc6311391209b0
Showing with 3 additions and 0 deletions.
  1. +3 −0 camptail.pl
View
@@ -115,6 +115,9 @@ sub read_rcfile {
sub setup_callback {
my (undef, $code) = @_;
if ($code =~ /[A-za-z0-9_]/) {
$code .= '(@_)';
}
$callback = eval <<EOF;
sub {
my (\$message, \$room) = \@_;

0 comments on commit 4a7d9bc

Please sign in to comment.