=cut
-our $Nick2Ident = Onis::Data::Persistent->new ('Nick2Ident', 'nick', 'ident');
+our $GeneralCounters = Onis::Data::Persistent->new ('GeneralCounters', 'key', 'value');
+our $NickToIdentCache = Onis::Data::Persistent->new ('NickToIdentCache', 'nick', 'ident');
our $ChatterList = Onis::Data::Persistent->new ('ChatterList', 'chatter', 'counter');
our $ChannelNames = Onis::Data::Persistent->new ('ChannelNames', 'channel', 'counter');
store unsharp calculate_nicks
get_all_nicks get_channel get_main_nick nick_to_ident ident_to_nick nick_to_name
- get_total_lines nick_rename print_output register_plugin
+ get_total_lines get_most_recent_time nick_rename print_output register_plugin
);
@Onis::Data::Core::ISA = ('Exporter');
+our $LinesThisRun = 0;
+
our $PluginCallbacks = {};
-our $OUTPUT = [];
+our $OutputCallbacks = [];
our @AllNicks = ();
-our @ALLNAMES = ();
our %NickToNick = ();
our %NickToIdent = ();
our %IdentToNick = ();
-our $LASTRUN_DAYS = 0;
-
-
-
our $UNSHARP = 'MEDIUM';
if (get_config ('unsharp'))
{
$data->{'user'} = $user;
$data->{'ident'} = $ident;
- $Nick2Ident->put ($nick, $ident);
+ $NickToIdentCache->put ($nick, $ident);
$chatter = "$nick!$ident";
($counter) = $ChatterList->get ($chatter);
$counter ||= 0; $counter++;
$ChatterList->put ($chatter, $counter);
}
- elsif (($ident) = $Nick2Ident->get ($nick))
+ elsif (($ident) = $NickToIdentCache->get ($nick))
{
my $chatter = "$nick!$ident";
my $counter;
}
}
- # TODO
- #$DATA->{'total_lines'}++;
+ {
+ my ($counter) = $GeneralCounters->get ('lines_total');
+ $counter ||= 0;
+ $counter++;
+ $GeneralCounters->put ('lines_total', $counter);
+
+ my ($time) = $GeneralCounters->get ('most_recent_time');
+ $time ||= 0;
+ $time = $data->{'epoch'} if ($time < $data->{'epoch'});
+ $GeneralCounters->put ('most_recent_time', $time);
+
+ $LinesThisRun++;
+ }
if (defined ($PluginCallbacks->{$type}))
{
}
else
{
- ($ident) = $Nick2Ident->get ($nick);
+ ($ident) = $NickToIdentCache->get ($nick);
$ident ||= '';
}
sub get_total_lines
{
- # TODO
- #return ($DATA->{'total_lines'});
+ my ($total) = $GeneralCounters->get ('lines_total');
+
+ return (qw()) unless ($total);
+
+ return ($total, $LinesThisRun);
+}
+
+=item I<$epoch> = B<get_most_recent_time> ()
+
+Returns the epoch of the most recent line received from the parser.
+
+=cut
+
+sub get_most_recent_time
+{
+ my ($time) = $GeneralCounters->get ('most_recent_time');
+ $time ||= 0;
+
+ return ($time);
}
=item B<nick_rename> (I<$old_nick>, I<$new_nick>)
my $new_nick = shift;
my $ident;
- ($ident) = $Nick2Ident->get ($old_nick);
+ ($ident) = $NickToIdentCache->get ($old_nick);
if (defined ($ident) and ($ident))
{
- $Nick2Ident->put ($new_nick, $ident);
+ $NickToIdentCache->put ($new_nick, $ident);
}
}
sub print_output
{
# FIXME FIXME FIXME
- if (!get_total_lines () and 0)
+ if (!get_total_lines ())
{
print STDERR <<'MESSAGE';
calculate_nicks ();
- for (@$OUTPUT)
+ for (@$OutputCallbacks)
{
&$_ ();
}
if ($type eq 'OUTPUT')
{
- push (@$OUTPUT, $sub_ref);
+ push (@$OutputCallbacks, $sub_ref);
}
else
{