Many many fixes. This version is actually kind of useable.
authorocto <octo>
Tue, 12 Apr 2005 08:18:54 +0000 (08:18 +0000)
committerocto <octo>
Tue, 12 Apr 2005 08:18:54 +0000 (08:18 +0000)
lib/Onis/Plugins/Conversations.pm
lib/Onis/Plugins/Core.pm
lib/Onis/Plugins/Interestingnumbers.pm
lib/Onis/Plugins/Topics.pm
lib/Onis/Plugins/Userdetails.pm

index 797d39c..5b28192 100644 (file)
@@ -3,6 +3,8 @@ package Onis::Plugins::Conversations;
 use strict;
 use warnings;
 
+use Exporter;
+
 use Onis::Config qw(get_config);
 use Onis::Html qw(get_filehandle);
 use Onis::Language qw(translate);
@@ -10,6 +12,9 @@ use Onis::Data::Core qw(register_plugin get_main_nick nick_to_ident nick_to_name
 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 = {};
 
@@ -210,7 +215,7 @@ EOF
                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;
 
@@ -227,7 +232,7 @@ EOF
                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;
 
index f3ace5a..1b05bab 100644 (file)
@@ -362,13 +362,13 @@ sub calculate
                        $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;
@@ -570,6 +570,7 @@ EOF
                my $nick = $_;
                my $ident = nick_to_ident ($nick);
                my $name  = ident_to_name ($ident);
+               my $print = $name || $nick;
 
                $linescount++;
 
@@ -580,11 +581,11 @@ EOF
                {
                        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 = '';
@@ -637,11 +638,11 @@ EOF
 
                        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')
@@ -751,7 +752,7 @@ EOF
                                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)
                        {
index de71f27..892dc09 100644 (file)
@@ -22,7 +22,7 @@ register_plugin ('TEXT', \&add_text);
 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 = '';
@@ -154,8 +154,8 @@ sub calculate
        {
                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);
 
@@ -167,20 +167,20 @@ sub calculate
                        {
                                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;
        }
 }
@@ -408,7 +408,7 @@ sub get_interestingnumbers
 {
        my $nick = shift;
 
-       if (defined ($InterestingNumbersData->{$nick}))
+       if (!defined ($InterestingNumbersData->{$nick}))
        {
                return ({});
        }
index 652ddfa..8f28fe7 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 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));
index 4a1250d..1f846a7 100644 (file)
@@ -146,9 +146,11 @@ sub output
        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 = $_;
@@ -160,14 +162,14 @@ sub output
                
                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);
                }
@@ -252,6 +254,8 @@ sub output
                        $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);
@@ -266,16 +270,16 @@ sub output
                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'});