mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Added Time::Duration::ago() to !info command
This commit is contained in:
parent
94076628a6
commit
f9ab0c7e77
@ -12,6 +12,8 @@ use vars qw($VERSION);
|
||||
$VERSION = $PBot::PBot::VERSION;
|
||||
|
||||
use Carp ();
|
||||
use Time::Duration;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
@ -361,19 +363,22 @@ sub info {
|
||||
return "/msg $nick $arguments not found";
|
||||
}
|
||||
|
||||
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};
|
||||
|
||||
# factoid
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'text') {
|
||||
return "$trigger: Factoid submitted by " . $factoids->{$channel}->{$trigger}->{owner} . " on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . ", referenced " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . ")";
|
||||
return "$trigger: Factoid submitted by " . $factoids->{$channel}->{$trigger}->{owner} . " on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " [$created_ago], referenced " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . (exists $factoids->{$channel}->{$trigger}->{last_referenced_on} ? " on " . localtime($factoids->{$channel}->{$trigger}->{last_referenced_on}) . " [$ref_ago]" : "") . ")";
|
||||
}
|
||||
|
||||
# module
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
return "$trigger: Module loaded by " . $factoids->{$channel}->{$trigger}->{owner} . " on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " -> http://code.google.com/p/pbot2-pl/source/browse/trunk/modules/" . $factoids->{$channel}->{$trigger}->{action} . ", used " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . ")";
|
||||
return "$trigger: Module loaded by " . $factoids->{$channel}->{$trigger}->{owner} . " on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " [$created_ago] -> http://code.google.com/p/pbot2-pl/source/browse/trunk/modules/" . $factoids->{$channel}->{$trigger}->{action} . ", used " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . (exists $factoids->{$channel}->{$trigger}->{last_referenced_on} ? " on " . localtime($factoids->{$channel}->{$trigger}->{last_referenced_on}) . " [$ref_ago]" : "") . ")";
|
||||
}
|
||||
|
||||
# regex
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'regex') {
|
||||
return "$trigger: Regex created by " . $factoids->{$channel}->{$trigger}->{owner} . " on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . ", used " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . ")";
|
||||
return "$trigger: Regex created by " . $factoids->{$channel}->{$trigger}->{owner} . " on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " [$created_ago], used " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . (exists $factoids->{$channel}->{$trigger}->{last_referenced_on} ? " on " . localtime($factoids->{$channel}->{$trigger}->{last_referenced_on}) . " [$ref_ago]" : "") . ")";
|
||||
}
|
||||
|
||||
return "/msg $nick $trigger is not a factoid or a module";
|
||||
|
@ -218,6 +218,7 @@ sub interpreter {
|
||||
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_count}++;
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_user} = $nick;
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on} = gettimeofday;
|
||||
|
||||
return $pbot->interpreter->interpret($from, $nick, $user, $host, $count, $command);
|
||||
}
|
||||
@ -230,6 +231,7 @@ sub interpreter {
|
||||
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_count}++;
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_user} = $nick;
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on} = gettimeofday;
|
||||
|
||||
return $self->{factoidmodulelauncher}->execute_module($from, $tonick, $nick, $user, $host, $keyword, $arguments);
|
||||
}
|
||||
@ -244,6 +246,7 @@ sub interpreter {
|
||||
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_count}++;
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_user} = $nick;
|
||||
$self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on} = gettimeofday;
|
||||
|
||||
$self->{pbot}->logger->log("(" . (defined $from ? $from : "(undef)") . "): $nick!$user\@$host): $keyword: Displaying text \"" . $self->factoids->hash->{$channel}->{$keyword}->{action} . "\"\n");
|
||||
|
||||
|
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 187,
|
||||
BUILD_DATE => "2010-06-20",
|
||||
BUILD_REVISION => 188,
|
||||
BUILD_DATE => "2010-06-21",
|
||||
};
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user