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

lagchecker: updated lagcheck bot command to use pong_received

This commit is contained in:
Pragmatic Software 2011-12-11 23:44:04 +00:00
parent 60ad02c9af
commit 242a0d5dfc
2 changed files with 26 additions and 1 deletions

View File

@ -126,6 +126,31 @@ sub lagstring {
sub lagcheck {
my ($self, $from, $nick, $user, $host, $arguments) = @_;
if(defined $self->{pong_received} and $self->{pong_received} == 0) {
# a ping has been sent (pong_received is not undef) and no pong has been received yet
my $elapsed = tv_interval($self->{ping_send_time});
my $lag_total = $elapsed;
my $len = @{ $self->{lag_history} };
my $lagstring = "";
my $comma = "";
foreach my $entry (@{ $self->{lag_history} }) {
my ($send_time, $lag_result) = @{ $entry };
$lag_total += $lag_result;
my $ago = ago(gettimeofday - $send_time);
$lagstring .= $comma . "[$ago] $lag_result";
$comma = "; ";
}
$lagstring .= $comma . "[waiting for pong] $elapsed";
my $average = $lag_total / ($len + 1);
$lagstring .= "; average: $average}";
return $lagstring;
}
return "My lag: " . $self->lagstring;
}

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 327,
BUILD_REVISION => 328,
BUILD_DATE => "2011-12-11",
};