diff --git a/PBot/LagChecker.pm b/PBot/LagChecker.pm index 31136152..63b76e12 100644 --- a/PBot/LagChecker.pm +++ b/PBot/LagChecker.pm @@ -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; } diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 556a2488..d117e7ed 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -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", };