3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-22 20:09:43 +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}->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 {
@ -314,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 eq '.*' ? 'default channel' : $channel) . ".";
return "/msg $nick $trigger removed from " . ($channel eq '.*' ? 'global channel' : $channel) . ".";
}
sub histogram {
@ -388,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 '.*' ? 'default channel' : $channel);
$chan = ($channel eq '.*' ? 'global channel' : $channel);
# factoid
if($factoids->{$channel}->{$trigger}->{type} eq 'text') {
@ -554,7 +554,7 @@ sub factfind {
$i++;
if($chan ne $last_chan) {
$text .= $chan eq '.*' ? "[default channel] " : "[$chan] ";
$text .= $chan eq '.*' ? "[global channel] " : "[$chan] ";
$last_chan = $chan;
}
$text .= "$trigger ";
@ -569,11 +569,11 @@ sub factfind {
if($i == 1) {
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 {
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";
}
}

View File

@ -120,13 +120,14 @@ sub export_factoids {
open FILE, "> $filename" or return "Could not open export path.";
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;
foreach my $channel (sort keys %{ $self->factoids->hash }) {
my $chan = $channel eq '.*' ? 'any' : $channel;
print FILE "<hr>\nChannel $chan\n<hr>\n";
my $chan = $channel eq '.*' ? 'Global channel' : "Channel $channel";
print FILE "<hr>\n$chan\n<hr>\n";
print FILE "<table border=\"0\">\n";
foreach my $trigger (sort keys %{ $self->factoids->hash->{$channel} }) {
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 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 "<hr>$i factoids memorized.<br>";
print FILE "<hr><i>Last updated at $time</i>\n";
close(FILE);

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 212,
BUILD_REVISION => 213,
BUILD_DATE => "2010-06-28",
};

View File

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