use warnings;
use Carp (qw(confess));
+use Exporter;
=head1 NAME
use Onis::Data::Core qw#get_all_nicks nick_to_ident ident_to_nick get_main_nick register_plugin#;
use Onis::Data::Persistent;
+@Onis::Plugins::Core::EXPORT_OK = (qw(get_core_nick_counters));
+@Onis::Plugins::Core::ISA = ('Exporter');
+
our $NickLinesCounter = Onis::Data::Persistent->new ('NickLinesCounter', 'nick',
qw(
lines00 lines01 lines02 lines03 lines04 lines05 lines06 lines07 lines08 lines09 lines10 lines11
our $QuoteCache = {}; # Saves per-nick information without any modification
our $QuoteData = {}; # Is generated before output. Nicks are merged according to Data::Core.
-our $NickData = {}: # Same as above, but for nicks rather than quotes.
+our $NickData = {}; # Same as above, but for nicks rather than quotes.
our @H_IMAGES = qw#dark-theme/h-red.png dark-theme/h-blue.png dark-theme/h-yellow.png dark-theme/h-green.png#;
our $QuoteCacheSize = 10;
{
@counter = qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0);
}
- $counter[$hour]++
+ $counter[$hour]++;
$NickLinesCounter->put ($nick, @counter);
@counter = $NickWordsCounter->get ($nick);
{
my $max = 0; # the most lines that were written in one hour..
my $total = 0; # the total amount of lines we wrote..
- my ($i, $j); # used in for-loops
my $factor = 0; # used to find a bar's height
- my $newline = ''; # buffer variable..
- my @data = @{$DATA->{'byhour'}};
+ my @data = qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0);
my @img_urls = get_config ('vertical_images');
if (!@img_urls)
# this for loop looks for the most amount of lines in one hour and sets
# $most_lines
- for ($i = 0; $i < 24; $i++)
+ for (keys %$NickData)
{
- if (!defined ($data[$i]))
+ my $nick = shift;
+
+ for (my $i = 0; $i < 24; $i++)
{
- next;
+ $data[$i] += $NickData->{$nick}{'chars'}[$i];
}
+ }
+ for (my $i = 0; $i < 24; $i++)
+ {
+ $max = $data[$i] if ($max < $data[$i]);
$total += $data[$i];
-
- if ($data[$i] > $max)
- {
- $max = $data[$i];
- }
}
if (!$total)
# this for circles through the four colors. Each color represents six hours.
# (4 * 6 hours = 24 hours)
- for ($i = 0; $i <= 3; $i++)
+ for (my $i = 0; $i <= 3; $i++)
{
- for ($j = 0; $j <= 5; $j++)
+ for (my $j = 0; $j <= 5; $j++)
{
my $hour = (($i * 6) + $j);
if (!defined ($data[$hour]))
my $total = 0;
if ($SORT_BY eq 'LINES')
{
- $total = $DATA->{'byname'}{$name}{'lines'};
+ $total = $NickData->{$nick}{'lines_total'};
}
elsif ($SORT_BY eq 'WORDS')
{
- $total = $DATA->{'byname'}{$name}{'words'};
+ $total = $NickData->{$nick}{'words_total'};
}
else # ($SORT_BY eq 'CHARS')
{
- $total = $DATA->{'byname'}{$name}{'chars'};
+ $total = $NickData->{$nick}{'chars_total'};
+ }
+
+ my $title = $name ? get_realname ($name) : '';
+ if (!$title)
+ {
+ $title = "User: $name; " if ($name);
+ $title .= "Ident: $ident";
}
if ($row_in_this_table == 0 and $col_in_this_table == 0)
qq# <tr>\n#;
}
- print $fh " <td>$name ($total)</td>\n";
+ print $fh qq# <td title="$title">$name ($total)</td>\n#;
if ($row_in_this_table == $ShortLines and $col_in_this_table == 5)
{
return ($retval);
}
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
+=item B<get_core_nick_counters> (I<$nick>)
+
+Returns the total I<lines>, I<words> and I<characters> written by the given
+nick.
+
+=cut
+
+sub get_core_nick_counters
+{
+ my $nick = shift;
+
+ if (defined ($NickData->{$nick}))
+ {
+ return ($NickData->{$nick}{'lines_total'},
+ $NickData->{$nick}{'words_total'},
+ $NickData->{$nick}{'chars_total'});
+ }
+
+ return (qw());
+}
+
+=back
+
=head1 AUTHOR
Florian octo Forster, E<lt>octo at verplant.orgE<gt>