3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 22:09:26 +01:00

Cleaned up extra factoid groups; made export factoids a little prettier; renamed "default channel" to "global channel" throughout

This commit is contained in:
Pragmatic Software 2010-06-29 06:12:52 +00:00
parent b869321eb4
commit 43089e4599
4 changed files with 13 additions and 16 deletions

View File

@ -282,7 +282,7 @@ sub factadd {
$self->{pbot}->factoids->add_factoid('text', $from_chan, $nick, $keyword, $text); $self->{pbot}->factoids->add_factoid('text', $from_chan, $nick, $keyword, $text);
$self->{pbot}->logger->log("$nick!$user\@$host added [$from_chan] $keyword => $text\n"); $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) . "."; return "/msg $nick '$keyword' added to " . ($from_chan eq '.*' ? 'global channel' : $from_chan) . ".";
} }
sub factrem { sub factrem {
@ -314,7 +314,7 @@ sub factrem {
$self->{pbot}->logger->log("$nick!$user\@$host removed [$channel][$trigger][" . $factoids->{$channel}->{$trigger}->{action} . "]\n"); $self->{pbot}->logger->log("$nick!$user\@$host removed [$channel][$trigger][" . $factoids->{$channel}->{$trigger}->{action} . "]\n");
$self->{pbot}->factoids->remove_factoid($channel, $trigger); $self->{pbot}->factoids->remove_factoid($channel, $trigger);
return "/msg $nick $trigger removed from " . ($channel eq '.*' ? 'default channel' : $channel) . "."; return "/msg $nick $trigger removed from " . ($channel eq '.*' ? 'global channel' : $channel) . ".";
} }
sub histogram { sub histogram {
@ -388,7 +388,7 @@ sub factinfo {
my $created_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{created_on}); 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}; my $ref_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{last_referenced_on}) if defined $factoids->{$channel}->{$trigger}->{last_referenced_on};
$chan = ($channel eq '.*' ? 'default channel' : $channel); $chan = ($channel eq '.*' ? 'global channel' : $channel);
# factoid # factoid
if($factoids->{$channel}->{$trigger}->{type} eq 'text') { if($factoids->{$channel}->{$trigger}->{type} eq 'text') {
@ -554,7 +554,7 @@ sub factfind {
$i++; $i++;
if($chan ne $last_chan) { if($chan ne $last_chan) {
$text .= $chan eq '.*' ? "[default channel] " : "[$chan] "; $text .= $chan eq '.*' ? "[global channel] " : "[$chan] ";
$last_chan = $chan; $last_chan = $chan;
} }
$text .= "$trigger "; $text .= "$trigger ";
@ -569,11 +569,11 @@ sub factfind {
if($i == 1) { if($i == 1) {
chop $text; chop $text;
return "found one factoid submitted for " . ($last_chan eq '.*' ? 'default channel' : $last_chan) . " " . $argtype . ": '$last_trigger' is '" . $factoids->{$last_chan}->{$last_trigger}->{action} . "'"; return "found one factoid submitted for " . ($last_chan eq '.*' ? 'global channel' : $last_chan) . " " . $argtype . ": '$last_trigger' is '" . $factoids->{$last_chan}->{$last_trigger}->{action} . "'";
} else { } else {
return "$i factoids " . $argtype . ": $text" unless $i == 0; return "$i factoids " . $argtype . ": $text" unless $i == 0;
my $chans = (defined $channel ? ($channel eq '.*' ? 'default channel' : $channel) : 'any channels'); my $chans = (defined $channel ? ($channel eq '.*' ? 'global channel' : $channel) : 'any channels');
return "No factoids " . $argtype . " submitted for $chans"; return "No factoids " . $argtype . " submitted for $chans";
} }
} }

View File

@ -120,13 +120,14 @@ sub export_factoids {
open FILE, "> $filename" or return "Could not open export path."; open FILE, "> $filename" or return "Could not open export path.";
my $time = localtime; my $time = localtime;
print FILE "<html><body><i>Generated at $time</i><hr><h3>Candide's factoids:</h3><br>\n"; print FILE "<html><body><i>Last updated at $time</i>\n";
print FILE "<hr><h3>Candide's factoids:</h3><br>\n";
my $i = 0; my $i = 0;
foreach my $channel (sort keys %{ $self->factoids->hash }) { foreach my $channel (sort keys %{ $self->factoids->hash }) {
my $chan = $channel eq '.*' ? 'any' : $channel; my $chan = $channel eq '.*' ? 'Global channel' : "Channel $channel";
print FILE "<hr>\nChannel $chan\n<hr>\n"; print FILE "<hr>\n$chan\n<hr>\n";
print FILE "<table border=\"0\">\n"; print FILE "<table border=\"0\">\n";
foreach my $trigger (sort keys %{ $self->factoids->hash->{$channel} }) { foreach my $trigger (sort keys %{ $self->factoids->hash->{$channel} }) {
if($self->factoids->hash->{$channel}->{$trigger}->{type} eq 'text') { if($self->factoids->hash->{$channel}->{$trigger}->{type} eq 'text') {
@ -139,13 +140,14 @@ sub export_factoids {
print FILE "<td><b>$trigger</b> is " . encode_entities($self->factoids->hash->{$channel}->{$trigger}->{action}) . "</td>\n"; print FILE "<td><b>$trigger</b> is " . encode_entities($self->factoids->hash->{$channel}->{$trigger}->{action}) . "</td>\n";
print FILE "<td align=\"right\">- submitted by<br> " . $self->factoids->hash->{$channel}->{$trigger}->{owner} . "<br><i>" . localtime($self->factoids->hash->{$channel}->{$trigger}->{created_on}) . "</i>\n</td>\n</tr>\n"; print FILE "<td align=\"right\">- submitted by " . $self->factoids->hash->{$channel}->{$trigger}->{owner} . "<br><i>" . localtime($self->factoids->hash->{$channel}->{$trigger}->{created_on}) . "</i>\n</td>\n</tr>\n";
} }
} }
print FILE "</table>\n"; print FILE "</table>\n";
} }
print FILE "<hr>$i factoids memorized.<br>"; print FILE "<hr>$i factoids memorized.<br>";
print FILE "<hr><i>Last updated at $time</i>\n";
close(FILE); close(FILE);

View File

@ -13,7 +13,7 @@ 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 => 212, BUILD_REVISION => 213,
BUILD_DATE => "2010-06-28", BUILD_DATE => "2010-06-28",
}; };

View File

@ -1,4 +1,3 @@
[]
[##c] [##c]
<test> <test>
action: /say A test in ##c! action: /say A test in ##c!
@ -23,7 +22,6 @@ ref_count: 2
ref_user: pragma_ ref_user: pragma_
type: text type: text
[#botters]
[#pbot2] [#pbot2]
<test> <test>
action: /say This is a test in #pbot2! action: /say This is a test in #pbot2!
@ -10581,6 +10579,3 @@ ref_count: 9
ref_user: pragma_ ref_user: pragma_
type: text type: text
[dave0]
[poppavic]
[pragma_]