From 2dfc95bddb9ea3e5c85503b1e6f529c4945cfe30 Mon Sep 17 00:00:00 2001 From: octo Date: Mon, 11 Apr 2005 21:53:04 +0000 Subject: [PATCH] Many fixes.. Many bugs left.. --- lib/Onis/Data/Core.pm | 29 ++++++++++++++++++++++++++--- lib/Onis/Data/Persistent/None.pm | 2 +- lib/Onis/Plugins/Bignumbers.pm | 3 +-- lib/Onis/Plugins/Conversations.pm | 14 ++++++++------ lib/Onis/Plugins/Core.pm | 5 ++--- lib/Onis/Plugins/Interestingnumbers.pm | 5 ++--- lib/Onis/Plugins/Nicks.pm | 10 +++++----- lib/Onis/Plugins/Topics.pm | 2 +- lib/Onis/Plugins/Urls.pm | 5 ++--- lib/Onis/Plugins/Userdetails.pm | 4 ++-- lib/Onis/Plugins/Words.pm | 3 +-- lib/Onis/Users.pm | 33 ++++----------------------------- onis | 2 +- 13 files changed, 56 insertions(+), 61 deletions(-) diff --git a/lib/Onis/Data/Core.pm b/lib/Onis/Data/Core.pm index e505dc4..4e7e05b 100644 --- a/lib/Onis/Data/Core.pm +++ b/lib/Onis/Data/Core.pm @@ -42,7 +42,7 @@ our $ChannelNames = Onis::Data::Persistent->new ('ChannelNames', 'channel', 'cou qw( store unsharp calculate_nicks - get_all_nicks get_channel get_main_nick nick_to_ident ident_to_nick + 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 ); @Onis::Data::Core::ISA = ('Exporter'); @@ -322,7 +322,7 @@ sub calculate_nicks for ($ChatterList->keys ()) { - my $chatter = shift; + my $chatter = $_; my ($nick, $ident) = split (m/!/, $chatter); my $name = ident_to_name ($ident); my ($counter) = $ChatterList->get ($chatter); @@ -604,6 +604,28 @@ sub ident_to_nick } } +=item I<$name> = B (I<$nick>) + +Return the name associated with I<$nick>. This function uses B +(see L). + +=cut + +sub nick_to_name +{ + my $nick = shift; + my $ident = nick_to_ident ($nick); + + if ($ident) + { + return (ident_to_name ($ident)); + } + else + { + return (''); + } +} + =item I<$lines> = B () Returns the total number of lines parsed so far. @@ -644,7 +666,8 @@ Print the output. Should be called only once.. sub print_output { - if (!get_total_lines ()) + # FIXME FIXME FIXME + if (!get_total_lines () and 0) { print STDERR <<'MESSAGE'; diff --git a/lib/Onis/Data/Persistent/None.pm b/lib/Onis/Data/Persistent/None.pm index 1dccf93..919fb5a 100644 --- a/lib/Onis/Data/Persistent/None.pm +++ b/lib/Onis/Data/Persistent/None.pm @@ -99,7 +99,7 @@ sub get if ($::DEBUG & 0x0200) { - print STDOUT $/, __FILE__, ': GET(', $obj->{'id'}, ', ', $key, ') = (' . join (', ', @{$obj->{'fields'}}) . ')'; + print STDOUT $/, __FILE__, ': GET(', $obj->{'id'}, ', ', $key, ') = (' . join (', ', @{$obj->{'data'}{$key}}) . ')'; } return (@{$obj->{'data'}{$key}}); diff --git a/lib/Onis/Plugins/Bignumbers.pm b/lib/Onis/Plugins/Bignumbers.pm index 2c6c7c1..00f298c 100644 --- a/lib/Onis/Plugins/Bignumbers.pm +++ b/lib/Onis/Plugins/Bignumbers.pm @@ -7,9 +7,8 @@ use Exporter; use Onis::Html (qw(get_filehandle)); use Onis::Language (qw(translate)); -use Onis::Data::Core (qw(get_main_nick register_plugin)); +use Onis::Data::Core (qw(get_main_nick register_plugin nick_to_name)); use Onis::Data::Persistent (); -use Onis::Users (qw(nick_to_name)); use Onis::Plugins::Core (qw(get_core_nick_counters)); @Onis::Plugins::Bignumbers::EXPORT_OK = (qw(get_bignumbers)); diff --git a/lib/Onis/Plugins/Conversations.pm b/lib/Onis/Plugins/Conversations.pm index 21ea588..797d39c 100644 --- a/lib/Onis/Plugins/Conversations.pm +++ b/lib/Onis/Plugins/Conversations.pm @@ -6,8 +6,8 @@ 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); -use Onis::Users qw(ident_to_name); +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; our $ConversationCache = Onis::Data::Persistent->new ('ConversationCache', 'partners', qw(time0 time1 time2 time3)); @@ -98,9 +98,10 @@ sub calculate $nick_from = get_main_nick ($nick_from); $nick_to = get_main_nick ($nick_to); - next if (!$nick_from or !$nick_to or ($nick_from eq $nick_to)); + next if (!$nick_from or !$nick_to); + next if ($nick_from eq $nick_to); - if ($ConversationData->{$nick_from}{$nick_to}) + if (!defined ($ConversationData->{$nick_from}{$nick_to})) { $ConversationData->{$nick_from}{$nick_to} = { @@ -158,6 +159,7 @@ sub output my @img = get_config ('horizontal_images'); + # FIXME my @data = get_top (10); return (undef) unless (@data); @@ -172,8 +174,8 @@ sub output for (my $i = 0; $i < 4; $i++) { - $sum0 += $rec->{'users'}{$nick0}[$i]; - $sum1 += $rec->{'users'}{$nick1}[$i]; + $sum0 += $rec->{'nicks'}{$nick0}[$i]; + $sum1 += $rec->{'nicks'}{$nick1}[$i]; } $max_num = $sum0 if ($max_num < $sum0); diff --git a/lib/Onis/Plugins/Core.pm b/lib/Onis/Plugins/Core.pm index c80359a..f3ace5a 100644 --- a/lib/Onis/Plugins/Core.pm +++ b/lib/Onis/Plugins/Core.pm @@ -414,7 +414,7 @@ sub activetimes # $most_lines for (keys %$NickData) { - my $nick = shift; + my $nick = $_; for (my $i = 0; $i < 24; $i++) { @@ -791,10 +791,9 @@ EOF sub bar { my $max_num = shift; - my $source = shift; - confess unless (ref ($source eq 'ARRAY')); + confess () unless (ref ($source) eq 'ARRAY'); # BAR_WIDTH is a least 10 my $max_width = $BAR_WIDTH - 4; diff --git a/lib/Onis/Plugins/Interestingnumbers.pm b/lib/Onis/Plugins/Interestingnumbers.pm index 6554bd4..de71f27 100644 --- a/lib/Onis/Plugins/Interestingnumbers.pm +++ b/lib/Onis/Plugins/Interestingnumbers.pm @@ -8,9 +8,8 @@ use Exporter; 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)); +use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_name)); use Onis::Data::Persistent; -use Onis::Users (qw(nick_to_name)); @Onis::Plugins::Interestingnumbers::EXPORT_OK = (qw(get_interestingnumbers)); @Onis::Plugins::Interestingnumbers::ISA = ('Exporter'); @@ -160,7 +159,7 @@ sub calculate $soliloquies) = $InterestingNumbersCache->get ($nick); my $main = get_main_nick ($nick); - die unless ($main); + next unless ($main); if (!defined ($InterestingNumbersData->{$main})) { diff --git a/lib/Onis/Plugins/Nicks.pm b/lib/Onis/Plugins/Nicks.pm index 6d30c6e..ec8f69c 100644 --- a/lib/Onis/Plugins/Nicks.pm +++ b/lib/Onis/Plugins/Nicks.pm @@ -3,11 +3,11 @@ package Onis::Plugins::Nicks; 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 nick_to_ident)); +use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_ident nick_to_name)); use Onis::Data::Persistent (); -use Onis::Users (qw(nick_to_name)); register_plugin ('TEXT', \&add); register_plugin ('ACTION', \&add); @@ -64,10 +64,10 @@ sub calculate $max = $tmp if ($tmp); } - for ($MentionedNicksData->keys ()) + for ($MentionedNicksCache->keys ()) { my $nick = $_; - my ($counter, $lastusedtime, $lastusedby) = $MentionedNicksData->get ($nick); + my ($counter, $lastusedtime, $lastusedby) = $MentionedNicksCache->get ($nick); die unless (defined ($lastusedby)); $lastusedby = get_main_nick ($lastusedby); @@ -75,7 +75,7 @@ sub calculate } @$MentionedNicksData = sort { $b->[1] <=> $a->[1] } (@data); - splice (@$MentionedNicksData, $max); + splice (@$MentionedNicksData, $max) if (scalar (@$MentionedNicksData) > $max); } sub output diff --git a/lib/Onis/Plugins/Topics.pm b/lib/Onis/Plugins/Topics.pm index 4f38fca..652ddfa 100644 --- a/lib/Onis/Plugins/Topics.pm +++ b/lib/Onis/Plugins/Topics.pm @@ -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)); +use Onis::Data::Core (qw(register_plugin nick_to_name)); use Onis::Data::Persistent (); our $TopicCache = Onis::Data::Persistent->new ('TopicCache', 'time', qw(text nick)); diff --git a/lib/Onis/Plugins/Urls.pm b/lib/Onis/Plugins/Urls.pm index 01ed084..32aa25a 100644 --- a/lib/Onis/Plugins/Urls.pm +++ b/lib/Onis/Plugins/Urls.pm @@ -6,9 +6,8 @@ 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 get_main_nick)); +use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_name)); use Onis::Data::Persistent (); -use Onis::Users (qw(nick_to_name)); register_plugin ('TEXT', \&add); register_plugin ('ACTION', \&add); @@ -67,7 +66,7 @@ sub calculate } @$URLData = sort { $b->[1] <=> $a->[1] } (@data); - splice (@$URLData, $max); + splice (@$URLData, $max) if (scalar (@$URLData) > $max); } sub output diff --git a/lib/Onis/Plugins/Userdetails.pm b/lib/Onis/Plugins/Userdetails.pm index 4d3edf7..4a1250d 100644 --- a/lib/Onis/Plugins/Userdetails.pm +++ b/lib/Onis/Plugins/Userdetails.pm @@ -6,10 +6,10 @@ 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(get_main_nick register_plugin)); +use Onis::Data::Core (qw(get_main_nick register_plugin nick_to_name)); use Onis::Users (qw(ident_to_name get_link get_image)); -use Onis::Plugins::Core (qw(get_core_nick_counters)); +use Onis::Plugins::Core (qw(get_core_nick_counters get_sorted_nicklist)); use Onis::Plugins::Conversations (qw(get_conversations)); use Onis::Plugins::Bignumbers (qw(get_bignumbers)); use Onis::Plugins::Interestingnumbers (qw(get_interestingnumbers)); diff --git a/lib/Onis/Plugins/Words.pm b/lib/Onis/Plugins/Words.pm index 65c1f7b..97109ec 100644 --- a/lib/Onis/Plugins/Words.pm +++ b/lib/Onis/Plugins/Words.pm @@ -6,9 +6,8 @@ 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)); +use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_ident nick_to_name)); use Onis::Data::Persistent (); -use Onis::Users (qw(nick_to_name)); register_plugin ('TEXT', \&add); register_plugin ('ACTION', \&add); diff --git a/lib/Onis/Users.pm b/lib/Onis/Users.pm index 9b07f15..89c6caa 100644 --- a/lib/Onis/Users.pm +++ b/lib/Onis/Users.pm @@ -3,13 +3,12 @@ package Onis::Users; use strict; use warnings; use Exporter; -use Onis::Config qw#get_config#; -use Onis::Data::Core qw(nick_to_ident); -use Onis::Data::Persistent; +use Onis::Config (qw(get_config)); +use Onis::Data::Persistent (); @Onis::Users::EXPORT_OK = (qw( - ident_to_name chatter_to_name nick_to_name name_to_ident + ident_to_name chatter_to_name name_to_ident get_realname get_link get_image )); @Onis::Users::ISA = ('Exporter'); @@ -24,12 +23,11 @@ Parses user-info and provides query-routines. The definition of "name" can be fo =head1 USAGE - use Onis::Users qw#ident_to_name chatter_to_name nick_to_name get_realname get_link get_image#; + use Onis::Users qw#ident_to_name chatter_to_name get_realname get_link get_image#; # Functions to query the name $name = ident_to_name ($ident); $name = chatter_to_name ($chatter); - $name = nick_to_name ($nick); # Functions to query a name's properties my $realname = get_realname ($name); @@ -244,29 +242,6 @@ sub chatter_to_name return (ident_to_name ($ident)); } -=item B (I<$nick>) - -Return the name associated with I<$nick>. This function uses B -(see L) to convert I<$nick> to an ident and then calls -B. - -=cut - -sub nick_to_name -{ - my $nick = shift; - my $ident = nick_to_ident ($nick); - - if ($ident) - { - return (ident_to_name ($ident)); - } - else - { - return (''); - } -} - =item B (I<$name>) Does the reverse of B: Returns the most recent association of diff --git a/onis b/onis index 94bcc73..c34fc74 100755 --- a/onis +++ b/onis @@ -27,7 +27,7 @@ BEGIN # 0x0400 Data::Core (dump incoming data to stderr) # 0x0800 Data::Core (initializing) # 0x1000 Onis::Users - $::DEBUG = 0x0200; + $::DEBUG = 0x0000; } use strict; -- 2.11.0