use strict;
use warnings;
+use Exporter;
+
use Onis::Config qw(get_config);
use Onis::Html qw(get_filehandle);
use Onis::Language qw(translate);
use Onis::Users (qw(ident_to_name));
use Onis::Data::Persistent;
+@Onis::Plugins::Conversations::EXPORT_OK = (qw(get_conversations));
+@Onis::Plugins::Conversations::ISA = ('Exporter');
+
our $ConversationCache = Onis::Data::Persistent->new ('ConversationCache', 'partners', qw(time0 time1 time2 time3));
our $ConversationData = {};
for (3, 2, 1, 0)
{
my $i = $img[$_];
- my $w = int (0.5 + ($rec->{'users'}{$nick0}[$_] * $factor));
+ my $w = int (0.5 + ($rec->{'nicks'}{$nick0}[$_] * $factor));
my $c = '';
$w ||= 1;
for (0, 1, 2, 3)
{
my $i = $img[$_];
- my $w = int (0.5 + ($rec->{'users'}{$nick1}[$_] * $factor));
+ my $w = int (0.5 + ($rec->{'nicks'}{$nick1}[$_] * $factor));
my $c = '';
$w ||= 1;
$NickData->{$main}{'words_total'} = $sum;
}
- @counter = $NickWordsCounter->get ($nick);
+ @counter = $NickCharsCounter->get ($nick);
if (@counter)
{
my $sum = 0;
for (my $i = 0; $i < 24; $i++)
{
- $NickData->{$main}{'words'}[$i] += $counter[$i];
+ $NickData->{$main}{'chars'}[$i] += $counter[$i];
$sum += $counter[$i];
}
$NickData->{$main}{'chars_total'} = $sum;
my $nick = $_;
my $ident = nick_to_ident ($nick);
my $name = ident_to_name ($ident);
+ my $print = $name || $nick;
$linescount++;
{
my $quote = translate ('-- no quote available --');
- if (defined ($QuoteData->{$nick}))
+ if (@{$QuoteData->{$nick}})
{
my $num = scalar (@{$QuoteData->{$nick}});
my $rand = int (rand ($num));
- $quote = html_escape ($QuoteData->{$nick}[$rand]);
+ $quote = html_escape ($QuoteData->{$nick}[$rand][1]);
}
my $link = '';
if ($link)
{
- print $fh qq#<a href="$link">$name</a></td>\n#
+ print $fh qq#<a href="$link">$print</a></td>\n#
}
else
{
- print $fh qq#$name</td>\n#;
+ print $fh qq#$print</td>\n#;
}
if ($DISPLAY_LINES ne 'NONE')
qq# <tr>\n#;
}
- print $fh qq# <td title="$title">$name ($total)</td>\n#;
+ print $fh qq# <td title="$title">$print ($total)</td>\n#;
if ($row_in_this_table == $ShortLines and $col_in_this_table == 5)
{
register_plugin ('OUTPUT', \&output);
our $InterestingNumbersCache = Onis::Data::Persistent->new ('InterestingNumbersCache', 'nick',
- qw(actions joins kicks_given kicks_received ops_given ops_taken soliloquies));
+ qw(actions joins kick_given kick_received op_given op_taken soliloquies));
our $InterestingNumbersData = {};
our $SoliloquiesNick = '';
{
my $nick = $_;
my ($actions, $joins,
- $kicks_given, $kicks_received,
- $ops_given, $ops_taken,
+ $kick_given, $kick_received,
+ $op_given, $op_taken,
$soliloquies) = $InterestingNumbersCache->get ($nick);
my $main = get_main_nick ($nick);
{
actions => 0,
joins => 0,
- kicks_given => 0,
- kicks_received => 0,
- ops_given => 0,
- ops_taken => 0,
+ kick_given => 0,
+ kick_received => 0,
+ op_given => 0,
+ op_taken => 0,
soliloquies => 0
};
}
$InterestingNumbersData->{$main}{'actions'} += $actions;
$InterestingNumbersData->{$main}{'joins'} += $joins;
- $InterestingNumbersData->{$main}{'kicks_given'} += $kicks_given;
- $InterestingNumbersData->{$main}{'kicks_received'} += $kicks_received;
- $InterestingNumbersData->{$main}{'ops_given'} += $ops_given;
- $InterestingNumbersData->{$main}{'ops_taken'} += $ops_taken;
+ $InterestingNumbersData->{$main}{'kick_given'} += $kick_given;
+ $InterestingNumbersData->{$main}{'kick_received'} += $kick_received;
+ $InterestingNumbersData->{$main}{'op_given'} += $op_given;
+ $InterestingNumbersData->{$main}{'op_taken'} += $op_taken;
$InterestingNumbersData->{$main}{'soliloquies'} += $soliloquies;
}
}
{
my $nick = shift;
- if (defined ($InterestingNumbersData->{$nick}))
+ if (!defined ($InterestingNumbersData->{$nick}))
{
return ({});
}
use Onis::Config (qw(get_config));
use Onis::Html (qw(html_escape get_filehandle));
use Onis::Language (qw(translate));
-use Onis::Data::Core (qw(register_plugin nick_to_name));
+use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_name));
use Onis::Data::Persistent ();
our $TopicCache = Onis::Data::Persistent->new ('TopicCache', 'time', qw(text nick));
my $max_time = 0;
my $max_conv = 0;
- my @nicks = $nicks_ref->[0 .. ($max - 1)];
+ my @nicks = @$nicks_ref;
my $nick_data = {};
+ splice (@nicks, $max) if (scalar (@nicks) > $max);
+
for (@nicks)
{
my $nick = $_;
for (my $i = 0; $i < 12; $i++)
{
- $num = $nick_data->{$nick}{'lines'}[2 * $i] + $nick_data->{$nick}{'lines'}[(2 * $i) + 1];
+ $num = $nick_data->{$nick}{'chars'}[2 * $i] + $nick_data->{$nick}{'chars'}[(2 * $i) + 1];
$max_time = $num if ($max_time < $num);
}
for (keys %{$nick_data->{$nick}{'conversations'}})
{
my $other = $_;
- my $ptr = $nick_data->{$nick}{'conversations'}{'nicks'}{$other};
+ my $ptr = $nick_data->{$nick}{'conversations'}{$other}{'nicks'}{$nick};
$num = $ptr->[0] + $ptr->[1] + $ptr->[2] + $ptr->[3];
$max_conv = $num if ($max_conv < $num);
}
$trans = translate ('Has written %u chars');
printf $fh (" $trans<br />\n", $chars);
+ $lines ||= 1;
+
$num = $words / $lines;
$trans = translate ('Has written %.1f words per line');
printf $fh (" $trans<br />\n", $num);
if (%{$ptr->{'interestingnumbers'}})
{
$trans = translate ('Has given %u ops');
- printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'ops_given'});
+ printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'op_given'});
$trans = translate ('Has taken %u ops');
- printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'ops_taken'});
+ printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'op_taken'});
$trans = translate ('Has kicked out %u people');
- printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'kicks_given'});
+ printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'kick_given'});
$trans = translate ('Has been kicked out %u times');
- printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'kicks_received'});
+ printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'kick_received'});
$trans = translate ('Has performed %u actions');
printf $fh (" $trans<br />\n", $ptr->{'interestingnumbers'}{'actions'});