mirror of
https://github.com/pragma-/pbot.git
synced 2025-10-07 19:47:27 +02: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;
|
$VERSION = $PBot::PBot::VERSION;
|
||||||
|
|
||||||
use Carp ();
|
use Carp ();
|
||||||
|
use Time::Duration;
|
||||||
|
use Time::HiRes qw(gettimeofday);
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
if(ref($_[1]) eq 'HASH') {
|
if(ref($_[1]) eq 'HASH') {
|
||||||
@ -361,19 +363,22 @@ sub info {
|
|||||||
return "/msg $nick $arguments not found";
|
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
|
# factoid
|
||||||
if($factoids->{$channel}->{$trigger}->{type} eq 'text') {
|
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
|
# module
|
||||||
if($factoids->{$channel}->{$trigger}->{type} eq '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
|
# regex
|
||||||
if($factoids->{$channel}->{$trigger}->{type} eq '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";
|
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_count}++;
|
||||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_user} = $nick;
|
$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);
|
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_count}++;
|
||||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_user} = $nick;
|
$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);
|
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_count}++;
|
||||||
$self->factoids->hash->{$channel}->{$keyword}->{ref_user} = $nick;
|
$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");
|
$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
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 187,
|
BUILD_REVISION => 188,
|
||||||
BUILD_DATE => "2010-06-20",
|
BUILD_DATE => "2010-06-21",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user