From b869321eb49f30b95291114bddb78513cf909514 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 29 Jun 2010 05:48:46 +0000 Subject: [PATCH] Adding factoid in /msg now adds factoid to default channel; replaced "all channels" with "default channel" throughout factoid command output --- PBot/FactoidCommands.pm | 16 +++++++------- PBot/Interpreter.pm | 2 +- PBot/VERSION.pm | 2 +- data/factoids | 46 ++--------------------------------------- 4 files changed, 13 insertions(+), 53 deletions(-) diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index fe6f8ce6..10bc39b9 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -269,6 +269,8 @@ sub factadd { return "/msg $nick Usage: factadd is "; } + $from_chan = '.*' if not $from_chan =~ m/^#/; + my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($from_chan, $keyword, undef, 1, 1); if(defined $trigger) { @@ -279,8 +281,8 @@ sub factadd { $self->{pbot}->factoids->add_factoid('text', $from_chan, $nick, $keyword, $text); - $self->{pbot}->logger->log("$nick!$user\@$host added $keyword => $text\n"); - return "/msg $nick '$keyword' added."; + $self->{pbot}->logger->log("$nick!$user\@$host added [$from_chan] $keyword => $text\n"); + return "/msg $nick '$keyword' added to " . ($from_chan eq '.*' ? 'default channel' : $from_chan) . "."; } sub factrem { @@ -312,7 +314,7 @@ sub factrem { $self->{pbot}->logger->log("$nick!$user\@$host removed [$channel][$trigger][" . $factoids->{$channel}->{$trigger}->{action} . "]\n"); $self->{pbot}->factoids->remove_factoid($channel, $trigger); - return "/msg $nick $trigger removed from channel $channel."; + return "/msg $nick $trigger removed from " . ($channel eq '.*' ? 'default channel' : $channel) . "."; } sub histogram { @@ -386,7 +388,7 @@ sub factinfo { my $created_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{created_on}); my $ref_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{last_referenced_on}) if defined $factoids->{$channel}->{$trigger}->{last_referenced_on}; - $chan = ($channel eq '.*' ? 'all channels' : $channel); + $chan = ($channel eq '.*' ? 'default channel' : $channel); # factoid if($factoids->{$channel}->{$trigger}->{type} eq 'text') { @@ -552,7 +554,7 @@ sub factfind { $i++; if($chan ne $last_chan) { - $text .= $chan eq '.*' ? "[all channels] " : "[$chan] "; + $text .= $chan eq '.*' ? "[default channel] " : "[$chan] "; $last_chan = $chan; } $text .= "$trigger "; @@ -567,11 +569,11 @@ sub factfind { if($i == 1) { chop $text; - return "found one factoid submitted for " . ($last_chan eq '.*' ? 'all channels' : $last_chan) . " " . $argtype . ": '$last_trigger' is '" . $factoids->{$last_chan}->{$last_trigger}->{action} . "'"; + return "found one factoid submitted for " . ($last_chan eq '.*' ? 'default channel' : $last_chan) . " " . $argtype . ": '$last_trigger' is '" . $factoids->{$last_chan}->{$last_trigger}->{action} . "'"; } else { return "$i factoids " . $argtype . ": $text" unless $i == 0; - my $chans = (defined $channel ? ($channel eq '.*' ? 'all channels' : $channel) : 'any channels'); + my $chans = (defined $channel ? ($channel eq '.*' ? 'default channel' : $channel) : 'any channels'); return "No factoids " . $argtype . " submitted for $chans"; } } diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 34147d78..54f0864f 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -185,7 +185,7 @@ sub interpret { if(defined $trigger) { ($keyword, $arguments) = ($k, "is $a"); } else { - ($keyword, $arguments) = ("factadd", "$from $k is $a"); + ($keyword, $arguments) = ("factadd", (defined $from ? $from : '.*' ) . " $k is $a"); } } elsif($command =~ /^(.*?)\s+(.*)$/) { ($keyword, $arguments) = ($1, $2); diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 9484355e..ee489201 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 => 211, + BUILD_REVISION => 212, BUILD_DATE => "2010-06-28", }; diff --git a/data/factoids b/data/factoids index 8b4c8f62..6ead1d28 100644 --- a/data/factoids +++ b/data/factoids @@ -23,28 +23,7 @@ ref_count: 2 ref_user: pragma_ type: text - -action: $args ur shit -created_on: 1277371322.68472 -enabled: 1 -last_referenced_on: 1277371333.81216 -owner: hateball -rate_limit: 15 -ref_count: 1 -ref_user: hateball -type: text - [#botters] - -action: lol -created_on: 1277286675.13114 -enabled: 1 -owner: pragma_ -rate_limit: 15 -ref_count: 0 -ref_user: nobody -type: text - [#pbot2] action: /say This is a test in #pbot2! @@ -10006,8 +9985,8 @@ ref_user: pragma_ type: text -action: /say PBot revision 210 2010-06-28 -created_on: 1277785832.35938 +action: /say PBot revision 212 2010-06-28 +created_on: 1277790321.9375 enabled: 1 last_referenced_on: 1277547370.96948 owner: pbot3 @@ -10603,26 +10582,5 @@ ref_user: pragma_ type: text [dave0] - -action: as dumb as a box of hair -created_on: 1277387092.24224 -enabled: 1 -last_referenced_on: 1277387118.69029 -owner: dave0 -rate_limit: 15 -ref_count: 1 -ref_user: dave0 -type: text - [poppavic] -<##c++> -action: For all of your C++ needs: ##C++: down the hall, left, down the stairs, ahead - next to the boiler room. -created_on: 1277459808.85581 -enabled: 1 -owner: PoppaVic -rate_limit: 15 -ref_count: 0 -ref_user: nobody -type: text - [pragma_]