mirror of https://github.com/pragma-/pbot.git
Add `add_nick` metadata key to tell modules to prepend nick to resulting text; unquote all spaces in module arguments
This commit is contained in:
parent
7388bf9cfc
commit
6e3dc6dba2
|
@ -62,7 +62,7 @@ sub execute_module {
|
||||||
$arguments =~ s/\$nick/$nick/g;
|
$arguments =~ s/\$nick/$nick/g;
|
||||||
|
|
||||||
$arguments = quotemeta($arguments);
|
$arguments = quotemeta($arguments);
|
||||||
$arguments =~ s/\\\s/ /;
|
$arguments =~ s/\\\s/ /g;
|
||||||
|
|
||||||
if(exists $self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{modulelauncher_subpattern}) {
|
if(exists $self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{modulelauncher_subpattern}) {
|
||||||
if($self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{modulelauncher_subpattern} =~ m/s\/(.*?)\/(.*)\//) {
|
if($self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{modulelauncher_subpattern} =~ m/s\/(.*?)\/(.*)\//) {
|
||||||
|
@ -80,6 +80,7 @@ sub execute_module {
|
||||||
$arguments =~ s/\$9/$i/g;
|
$arguments =~ s/\$9/$i/g;
|
||||||
$arguments =~ s/\$`/$before/g;
|
$arguments =~ s/\$`/$before/g;
|
||||||
$arguments =~ s/\$'/$after/g;
|
$arguments =~ s/\$'/$after/g;
|
||||||
|
$self->{pbot}->logger->log("arguments subpattern: $arguments\n");
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->logger->log("Invalid module substitution pattern [" . $self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{modulelauncher_subpattern}. "], ignoring.\n");
|
$self->{pbot}->logger->log("Invalid module substitution pattern [" . $self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{modulelauncher_subpattern}. "], ignoring.\n");
|
||||||
}
|
}
|
||||||
|
@ -129,11 +130,12 @@ sub execute_module {
|
||||||
Carp::croak("Could not chdir to '$module_dir': $!");
|
Carp::croak("Could not chdir to '$module_dir': $!");
|
||||||
}
|
}
|
||||||
|
|
||||||
# print "module arguments: [$arguments]\n";
|
# $self->{pbot}->logger->log("module arguments: [$arguments]\n");
|
||||||
|
|
||||||
|
$text = `$module_dir/$module $arguments`;
|
||||||
|
|
||||||
if(defined $tonick) {
|
if(defined $tonick) {
|
||||||
$self->{pbot}->logger->log("($from): $nick!$user\@$host) sent to $tonick\n");
|
$self->{pbot}->logger->log("($from): $nick!$user\@$host) sent to $tonick\n");
|
||||||
$text = `$module_dir/$module $arguments`;
|
|
||||||
if(defined $text && length $text > 0) {
|
if(defined $text && length $text > 0) {
|
||||||
# get rid of original caller's nick
|
# get rid of original caller's nick
|
||||||
$text =~ s/^\/([^ ]+) \Q$nick\E:\s+/\/$1 /;
|
$text =~ s/^\/([^ ]+) \Q$nick\E:\s+/\/$1 /;
|
||||||
|
@ -144,7 +146,11 @@ sub execute_module {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return `$module_dir/$module $arguments`;
|
if(exists $self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{add_nick} and $self->{pbot}->factoids->factoids->hash->{$channel}->{$trigger}->{add_nick} != 0) {
|
||||||
|
return "$nick: $text";
|
||||||
|
} else {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "/me moans loudly."; # er, didn't execute the module?
|
return "/me moans loudly."; # er, didn't execute the module?
|
||||||
|
|
|
@ -13,8 +13,8 @@ use warnings;
|
||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 483,
|
BUILD_REVISION => 484,
|
||||||
BUILD_DATE => "2014-02-22",
|
BUILD_DATE => "2014-02-23",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue