3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-01-03 08:32:42 +01:00

Don't expand escaped dollar-signs in factoids

This commit is contained in:
Pragmatic Software 2007-07-04 01:52:59 +00:00
parent ff4648cf4d
commit 24a59a90e0

View File

@ -119,9 +119,9 @@ my $commands_file = "$home/pbot2/commands";
my $admins_file = "$home/pbot2/admins"; my $admins_file = "$home/pbot2/admins";
my $module_dir = "$home/pbot2/modules"; my $module_dir = "$home/pbot2/modules";
my $ircserver = 'irc.freenode.net'; my $ircserver = 'irc.freenode.net';
my $botnick = 'pbot2'; my $botnick = 'candide';
my $altbotnick = 'pbot2_'; my $altbotnick = 'candide_';
my $identify_password = '*'; my $identify_password = 'pop';
my $export_factoids_timeout = 300; # every 5 minutes my $export_factoids_timeout = 300; # every 5 minutes
my $export_factoids_path = "$home/htdocs/candide/factoids.html"; my $export_factoids_path = "$home/htdocs/candide/factoids.html";
@ -138,14 +138,14 @@ my %commands = ( version => {
ref_user => "nobody" } ref_user => "nobody" }
); );
my %admins = ( admin_nick => { my %admins = ( pragma_ => {
password => '*', password => '*',
level => 50, level => 50,
host => "blackshell.com" }, host => "blackshell.com" },
another_admin => { _pragma => {
password => '*', password => '*',
level => 50, level => 50,
host => ".*.wildcard.edu" } host => ".*.tmcc.edu" }
); );
my %channels = (); my %channels = ();
@ -1111,17 +1111,19 @@ sub interpret_command {
$text =~ s/\$args/$nick/gi; $text =~ s/\$args/$nick/gi;
} }
$text =~ s/\$nick/$nick/g; $text =~ s/\$nick/$nick/g;
while($text =~ /\$([^\s!\+\.\$\/\\,;]+)/) { while($text =~ /[^\\]\$([^\s!+.$\/\\,;]+)/g) {
my $var = $1; my $var = $1;
#plog "adlib: got [$var]\n";
#plog "adlib: parsing variable [\$$var]\n"; #plog "adlib: parsing variable [\$$var]\n";
if(exists $commands{$var} && exists $commands{$var}{text}) { if(exists $commands{$var} && exists $commands{$var}{text}) {
my $change = $commands{$var}{text}; my $change = $commands{$var}{text};
my @list = split(/\s|(".*?")/, $change); my @list = split(/\s|(".*?")/, $change);
my @mylist; my @mylist;
#plog "adlib: list [". join(':', @mylist) ."]\n";
for(my $i = 0; $i <= $#list; $i++) { for(my $i = 0; $i <= $#list; $i++) {
#plog "adlib: pushing $i $list[$i]\n";
push @mylist, $list[$i] if $list[$i]; push @mylist, $list[$i] if $list[$i];
} }
#plog "adlib: list [". join(':', @mylist) ."]\n";
my $line = int(rand($#mylist + 1)); my $line = int(rand($#mylist + 1));
$mylist[$line] =~ s/"//g; $mylist[$line] =~ s/"//g;
$text =~ s/\$$var/$mylist[$line]/; $text =~ s/\$$var/$mylist[$line]/;
@ -1131,6 +1133,7 @@ sub interpret_command {
#plog "adlib: not found: change: $text\n"; #plog "adlib: not found: change: $text\n";
} }
} }
$text =~ s/\\\$/\$/g;
if($text =~ s/^\/say\s+//i || $text =~ /^\/me\s+/i if($text =~ s/^\/say\s+//i || $text =~ /^\/me\s+/i
|| $text =~ /^\/msg\s+/i) { || $text =~ /^\/msg\s+/i) {
return $text; return $text;