From 921c9917a51d9fe8d8e65b11079a1a3c60636141 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 4 Mar 2014 21:40:13 +0000 Subject: [PATCH] Add $channel special variable for factoids/modules that expands to $from parameter --- PBot/FactoidModuleLauncher.pm | 1 + PBot/Factoids.pm | 1 + PBot/Interpreter.pm | 2 +- PBot/VERSION.pm | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PBot/FactoidModuleLauncher.pm b/PBot/FactoidModuleLauncher.pm index afe68cd9..11f41ae1 100644 --- a/PBot/FactoidModuleLauncher.pm +++ b/PBot/FactoidModuleLauncher.pm @@ -60,6 +60,7 @@ sub execute_module { $self->{pbot}->logger->log("(" . (defined $from ? $from : "(undef)") . "): $nick!$user\@$host: Executing module $module $arguments\n"); $arguments =~ s/\$nick/$nick/g; + $arguments =~ s/\$channel/$from/g; $arguments = quotemeta($arguments); $arguments =~ s/\\\s/ /g; diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 1859bced..dc185b8d 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -455,6 +455,7 @@ sub interpreter { $self->{pbot}->logger->log("(" . (defined $from ? $from : "(undef)") . "): $nick!$user\@$host): $keyword: Displaying text \"" . $result . "\"\n"); $result =~ s/\$nick/$nick/g; + $result =~ s/\$channel/$from/g; while ($result =~ /[^\\]\$([a-zA-Z0-9_\-]+)/g) { #$self->{pbot}->logger->log("adlib: looking for [$1]\n"); diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 1b77cc8e..2c91a5df 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -135,7 +135,7 @@ sub process_line { if(defined $has_url) { $result = $self->{pbot}->factoids->{factoidmodulelauncher}->execute_module($from, undef, $nick, $user, $host, "title", "$nick http://$has_url"); } elsif(defined $has_code) { - $result = $self->{pbot}->factoids->{factoidmodulelauncher}->execute_module($from, undef, $nick, $user, $host, "compiler_block", (defined $nick_override ? $nick_override : $nick) . " $has_code }"); + $result = $self->{pbot}->factoids->{factoidmodulelauncher}->execute_module($from, undef, $nick, $user, $host, "compiler_block", (defined $nick_override ? $nick_override : $nick) . " $from $has_code }"); } else { $result = $self->interpret($from, $nick, $user, $host, 1, $command); } diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index e6b58f4c..c627067d 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 501, + BUILD_REVISION => 502, BUILD_DATE => "2014-03-04", };