From: octo Date: Fri, 15 Apr 2005 20:38:37 +0000 (+0000) Subject: Added documentation to the Interestingnumbers, Bignumbers and Conversations plugins... X-Git-Tag: Release-0.8.0~18 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bf61c85ba4eb614a955c607b39e310fde9463cc3;p=onis.git Added documentation to the Interestingnumbers, Bignumbers and Conversations plugins. The rest will follow. Added a first prototype of longterm-statistics.. Not useable yet.. --- diff --git a/lib/Onis/Plugins/Bignumbers.pm b/lib/Onis/Plugins/Bignumbers.pm index 0332ee4..ab862d1 100644 --- a/lib/Onis/Plugins/Bignumbers.pm +++ b/lib/Onis/Plugins/Bignumbers.pm @@ -11,6 +11,19 @@ use Onis::Data::Core (qw(get_main_nick register_plugin nick_to_name)); use Onis::Data::Persistent (); use Onis::Plugins::Core (qw(get_core_nick_counters nick_is_in_main_table)); +=head1 NAME + +Onis::Plugins::Bignumbers - Information about nick specific channel +characteristics + +=head1 DESCRIPTION + +This plugins detects questions, yelled text (all uppercase), (happy and sad) +smileys, characters and words per line. It stores this information for each +nick and prints a table containing the most significant nicks in each category. + +=cut + @Onis::Plugins::Bignumbers::EXPORT_OK = (qw(get_bignumbers)); @Onis::Plugins::Bignumbers::ISA = ('Exporter'); @@ -399,6 +412,26 @@ sub sort_by_field return (@retval); } +=head1 EXPORTED FUNCTIONS + +=over 4 + +=item B (I<$nick>) + +Returns all the data that was used to calculate the bignumbers-data for this +nick. It's a hash-ref with the following fields. Each field holds a counter +that counts the total occurences of that "event". + + lines + words + chars + questions + uppercase + smiley_happy + smiley_sad + +=cut + sub get_bignumbers { my $nick = shift; @@ -410,3 +443,11 @@ sub get_bignumbers return ($CalcData->{$nick}); } + +=back + +=head1 AUTHOR + +Florian Forster Eocto at verplant.orgE + +=cut diff --git a/lib/Onis/Plugins/Conversations.pm b/lib/Onis/Plugins/Conversations.pm index 5b28192..6f745d4 100644 --- a/lib/Onis/Plugins/Conversations.pm +++ b/lib/Onis/Plugins/Conversations.pm @@ -12,6 +12,17 @@ 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; +=head1 NAME + +Onis::Plugins::Conversations - Who talks with who + +=head1 DESCRIPTION + +This plugins tries to recignise conversations and counts the amount that people +talk to each other. + +=cut + @Onis::Plugins::Conversations::EXPORT_OK = (qw(get_conversations)); @Onis::Plugins::Conversations::ISA = ('Exporter'); @@ -249,6 +260,33 @@ EOF print $fh "\n\n"; } +=head1 EXPORTED FUNCTIONS + +=over 4 + +=item B (I<$nick>) + +Returns a hashref to the conversations this nick was involved with. The layout +is the following. I<$other> is the nick of the person I<$nick> chattet with. +The arrays hold the number of characters written by the nick used as the key. +The first field contains the characters for the hours 0-5, the second field +holds 6-11 and so on. + + { + $other => + { + total => 0, + nicks => + { + $nick => [0, 0, 0, 0], + $other => [0, 0, 0, 0] + } + }, + ... + } + +=cut + sub get_conversations { my $nick = shift; @@ -262,3 +300,11 @@ sub get_conversations return ($ConversationData->{$nick}); } } + +=back + +=head1 AUTHOR + +Florian octo Forster, Eocto at verplant.orgE + +=cut diff --git a/lib/Onis/Plugins/Interestingnumbers.pm b/lib/Onis/Plugins/Interestingnumbers.pm index 4397db6..b7e9b24 100644 --- a/lib/Onis/Plugins/Interestingnumbers.pm +++ b/lib/Onis/Plugins/Interestingnumbers.pm @@ -11,6 +11,17 @@ use Onis::Language (qw(translate)); use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_name)); use Onis::Data::Persistent; +=head1 NAME + +Onis::Plugins::Interestingnumbers + +=head1 DESCRIPTION + +Counts actions, joins, given and received kicks and ops and soliloquies for +each nick and prints the most significant nicks in a table. + +=cut + @Onis::Plugins::Interestingnumbers::EXPORT_OK = (qw(get_interestingnumbers)); @Onis::Plugins::Interestingnumbers::ISA = ('Exporter'); @@ -406,6 +417,25 @@ sub sort_by_field return (@retval); } +=head1 EXPORTED FUNCTIONS + +=over 4 + +=item B (I<$nick>) + +Returns a hash-ref with the interesting numbers (counters) for this nick. The +hash-ref has the following fields: + + actions + joins + kick_given + kick_received + op_given + op_taken + soliloquies + +=cut + sub get_interestingnumbers { my $nick = shift; @@ -417,3 +447,11 @@ sub get_interestingnumbers return ($InterestingNumbersData->{$nick}); } + +=back + +=head1 AUTHOR + +Florian octo Forster, Eocto at verplant.orgE + +=cut diff --git a/lib/Onis/Plugins/Longterm.pm b/lib/Onis/Plugins/Longterm.pm new file mode 100644 index 0000000..0ca0f6b --- /dev/null +++ b/lib/Onis/Plugins/Longterm.pm @@ -0,0 +1,190 @@ +package Onis::Plugins::Weekdays; + +use strict; +use warnings; + +use Onis::Config (qw(get_config)); +use Onis::Html (qw(get_filehandle)); +use Onis::Language (qw(translate)); +use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_ident nick_to_name)); +use Onis::Data::Persistent (); + +register_plugin ('TEXT', \&add); +register_plugin ('ACTION', \&add); +register_plugin ('OUTPUT', \&output); + +our $LongtermLastSeen = Onis::Data::Persistent->new ('LongtermLastSeen', 'nick', 'day'); +our $LongtermCache = Onis::Data::Persistent->new ('LongtermCache', 'key', qw(time0 time1 time2 time3)); + +=head1 CONFIGURATION OPTIONS + +=over 4 + +=item B: I, I, I, I; + +Sets the images to use for vertical graphs. + +=cut + +our @VImages = get_config ('vertical_images'); +if (scalar (@VImages) != 4) +{ + @VImages = qw#images/ver0n.png images/ver1n.png images/ver2n.png images/ver3n.png#; +} + +=item B: I<31>; + +Sets the number of days displayed by this plugin. + +=cut + +our $DisplayDays = 31; +if (get_config ('longterm_days')) +{ + my $tmp = get_config ('longterm_days'); + $tmp =~ s/\D//g; + $DisplayDays = $tmp if ($tmp); +} + +=back + +=cut + +my $VERSION = '$Id$'; +print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG); + +return (1); + +sub add +{ + my $data = shift; + my $nick = $data->{'nick'}; + my $time = $data->{'epoch'}; + my $hour = int ($data->{'hour'} / 6); + my $chars = length ($data->{'text'}); + my $day = int ($time / 86400); + my $index = ($day * 4) + $hour; + + my ($lastseen) = $LongtermLastSeen->get ($nick); + $lastseen ||= $day; + + for (my $i = $lastseen; $i < $day; $i++) + { + my $last = $i - $DisplayDays; + $LongtermCache->del ($nick . ':' . $last); + + if ($i != $lastseen) + { + $LongtermCache->put ($nick . ':' . $i, qw(0 0 0 0)); + } + } + + my @data = $LongtermCache->get ($nick . ':' . $day); + @data = (qw(0 0 0 0)) unless (@data); + $data[$hour] += $chars; + $LongtermCache->put ($nick . ':' . $day, @data); + + $LongtermLastSeen->put ($nick, $day); +} + +sub calculate +{ + for ($WeekdayCache->keys ()) + { + my $nick = $_; + my $main = $nick eq '' ? '' : get_main_nick ($nick); + my @data = $WeekdayCache->get ($nick); + + if (!defined ($WeekdayData->{$main})) + { + $WeekdayData->{$main} = + { + sun => [0, 0, 0, 0], + mon => [0, 0, 0, 0], + tue => [0, 0, 0, 0], + wed => [0, 0, 0, 0], + thu => [0, 0, 0, 0], + fri => [0, 0, 0, 0], + sat => [0, 0, 0, 0] + }; + } + + for (my $i = 0; $i < 7; $i++) + { + my $day = $Weekdays[$i]; + for (my $j = 0; $j < 4; $j++) + { + my $idx = ($i * 4) + $j; + $WeekdayData->{$main}{$day}[$j] += $data[$idx]; + } + } + } +} + +sub output +{ + calculate (); + return (undef) unless (%$WeekdayData); + + my @order = + ( + [1, 'mon', 'Monday'], + [2, 'tue', 'Tuesday'], + [3, 'wed', 'Wednesday'], + [4, 'thu', 'Thursday'], + [5, 'fri', 'Friday'], + [6, 'sat', 'Saturday'], + [0, 'sun', 'Sunday'] + ); + + my $data = $WeekdayData->{''}; + + my $fh = get_filehandle (); + + my $max = 0; + my $total = 0; + my $bar_factor = 0; + + for (@order) + { + my ($num, $abbr, $name) = @$_; + + for (my $i = 0; $i < 4; $i++) + { + $max = $data->{$abbr}[$i] if ($max < $data->{$abbr}[$i]); + $total += $data->{$abbr}[$i]; + } + } + + $bar_factor = $BarHeight / $max; + + print $fh qq#\n \n#; + for (@order) + { + my ($num, $abbr, $name) = @$_; + for (my $i = 0; $i < 4; $i++) + { + my $num = $data->{$abbr}[$i]; + my $height = sprintf ("%.2f", (95 * $num / $max)); + my $img = $VImages[$i]; + + print $fh qq# \n); + } + } + print $fh qq( \n \n); + for (@order) + { + my ($num, $abbr, $name) = @$_; + my $sum = $data->{$abbr}[0] + $data->{$abbr}[1] + $data->{$abbr}[2] + $data->{$abbr}[3]; + my $pct = sprintf ("%.1f", (100 * $sum / $total)); + print $fh qq( \n); + } + print $fh qq( \n \n); + for (@order) + { + my ($num, $abbr, $name) = @$_; + print $fh qq( \n); + } + print $fh " \n
#, + qq(
$pct%
$name
\n\n"; +}