use Exporter;
use Onis::Config qw(get_config);
-use Onis::Users qw(ident_to_name);
+use Onis::Users qw(chatter_to_name);
use Onis::Data::Persistent;
use Onis::Parser::Persistent qw(get_absolute_time);
qw(
store unsharp calculate_nicks
- get_all_nicks get_channel get_main_nick nick_to_ident ident_to_nick nick_to_name
+ get_all_nicks get_channel get_main_nick
+ nick_to_ident ident_to_nick
+ nick_to_name ident_to_name
get_total_lines get_most_recent_time nick_rename print_output register_plugin
);
@Onis::Data::Core::ISA = ('Exporter');
{
my $chatter = $_;
my ($nick, $ident) = split (m/!/, $chatter);
- my $name = ident_to_name ($ident);
my ($counter) = $ChatterList->get ($chatter);
$nicks->{$nick}{$ident} = 0 unless (defined ($nicks->{$nick}{$ident}));
for (keys %{$nicks->{$this_nick}})
{
my $ident = $_;
- my $name = ident_to_name ($ident);
+ my $name = chatter_to_name ("$this_nick!$ident");
my $num = $nicks->{$this_nick}{$ident};
$this_total += $num;
=item I<$name> = B<nick_to_name> (I<$nick>)
-Return the name associated with I<$nick>. This function uses B<ident_to_name>
-(see L<Onis::Users>).
+Return the name associated with I<$nick>.
=cut
if ($ident)
{
- return (ident_to_name ($ident));
+ return (chatter_to_name ("$nick!$ident"));
+ }
+ else
+ {
+ return ('');
+ }
+}
+
+=item I<$name> = B<ident_to_name> (I<$ident>)
+
+Returns the name associated with I<$ident>.
+
+=cut
+
+sub ident_to_name
+{
+ my $ident = shift;
+ my $nick = ident_to_nick ($ident);
+
+ if ($nick)
+ {
+ return (chatter_to_name ("$nick!$ident"));
}
else
{
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::Users (qw(ident_to_name));
use Onis::Data::Persistent;
=head1 NAME
use Onis::Config (qw(get_config));
use Onis::Html (qw(html_escape get_filehandle));
use Onis::Language (qw(translate));
-use Onis::Users (qw(get_realname get_link get_image ident_to_name));
+use Onis::Users (qw(get_realname get_link get_image chatter_to_name));
use Onis::Data::Core (qw(get_all_nicks nick_to_ident ident_to_nick get_main_nick register_plugin));
use Onis::Data::Persistent ();
{
my $nick = $_;
my $ident = nick_to_ident ($nick);
- my $name = ident_to_name ($ident);
+ my $name = chatter_to_name ("$nick!$ident");
my $print = $name || $nick;
$linescount++;
=head1 AUTHOR
-Florian octo Forster, E<lt>octo at verplant.orgE<gt>
+Florian octo Forster E<lt>octo at verplant.orgE<gt>
=cut
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::Data::Core (qw(register_plugin get_main_nick get_most_recent_time nick_to_ident nick_to_name));
use Onis::Data::Persistent ();
+=head1 NAME
+
+Onis::Plugins::Longterm
+
+=cut
+
+@Onis::Plugins::Longterm::EXPORT_OK = (qw(get_longterm));
+@Onis::Plugins::Longterm::ISA = ('Exporter');
+
register_plugin ('TEXT', \&add);
register_plugin ('ACTION', \&add);
register_plugin ('OUTPUT', \&output);
}
print $fh " </tr>\n</table>\n\n";
}
+
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
+=item B<get_longterm> (I<$nick>)
+
+Returns the longterm-statistics for I<$nick>. The numbers are array-counters.
+The format is as follows:
+
+ [
+ [0, 0, 0, 0], # oldest day
+ ...,
+ [0, 0, 0, 0], # yesterday
+ [0, 0, 0, 0] # today
+ ]
+
+=cut
+
+sub get_longterm
+{
+ my $nick = shift;
+
+ if (!defined ($LongtermData->{$nick}))
+ {
+ return ([]);
+ }
+
+ return ($LongtermData->{$nick});
+}
+
+=back
+
+=head1 AUTHOR
+
+Florian octo Forster E<lt>octo at verplant.orgE<gt>
+
+=cut
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 nick_to_name));
-use Onis::Users (qw(ident_to_name get_link get_image));
+use Onis::Data::Core (qw(get_main_nick register_plugin nick_to_name get_most_recent_time));
+use Onis::Users (qw(get_link get_image));
use Onis::Plugins::Core (qw(get_core_nick_counters get_sorted_nicklist));
use Onis::Plugins::Weekdays (qw(get_weekdays));
+use Onis::Plugins::Longterm (qw(get_longterm));
use Onis::Plugins::Conversations (qw(get_conversations));
use Onis::Plugins::Bignumbers (qw(get_bignumbers));
use Onis::Plugins::Interestingnumbers (qw(get_interestingnumbers));
$BAR_WIDTH = $tmp if ($tmp >= 10);
}
+our $LongtermDays = 7;
+if (get_config ('userdetails_longterm_days'))
+{
+ my $tmp = get_config ('userdetails_longterm_days');
+ $tmp =~ s/\D//g;
+ $LongtermDays = $tmp if ($tmp);
+}
+
my $VERSION = '$Id: Userdetails.pm,v 1.5 2005/03/14 18:40:25 octo Exp $';
print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG);
my $max_time = 0;
my $max_conv = 0;
- my $max_weekday = 0;
+ my $max_weekdays = 0;
+ my $max_longterm = 0;
my @nicks = @$nicks_ref;
my $nick_data = {};
$nick_data->{$nick} = get_core_nick_counters ($nick);
$nick_data->{$nick}{'weekdays'} = get_weekdays ($nick);
+ $nick_data->{$nick}{'longterm'} = get_longterm ($nick);
$nick_data->{$nick}{'conversations'} = get_conversations ($nick);
$nick_data->{$nick}{'bignumbers'} = get_bignumbers ($nick);
$nick_data->{$nick}{'interestingnumbers'} = get_interestingnumbers ($nick);
for (keys %{$nick_data->{$nick}{'weekdays'}})
{
- my $day = $_;
- my $ptr = $nick_data->{$nick}{'weekdays'}{$day};
-
+ my $ptr = $nick_data->{$nick}{'weekdays'}{$_};
for (my $i = 0; $i < 4; $i++)
{
- $max_weekday = $ptr->[$i] if ($max_weekday < $ptr->[$i]);
+ $max_weekdays = $ptr->[$i] if ($max_weekdays < $ptr->[$i]);
}
}
- }
- my $time_factor = 0;
- my $conv_factor = 0;
+ if (@{$nick_data->{$nick}{'longterm'}})
+ {
+ my $num = scalar (@{$nick_data->{$nick}{'longterm'}});
+ $LongtermDays = $num if ($LongtermDays > $num);
- if ($max_time)
- {
- $time_factor = $BAR_HEIGHT / $max_time;
- }
+ for (my $i = $num - $LongtermDays; $i < $num; $i++)
+ {
+ my $ptr = $nick_data->{$nick}{'longterm'}[$i];
- if ($max_conv)
- {
- $conv_factor = $BAR_WIDTH / $max_conv;
+ for (my $j = 0; $j < 4; $j++)
+ {
+ $max_longterm = $ptr->[$j] if ($max_longterm < $ptr->[$j]);
+ }
+ }
+ }
}
-
+
print $fh qq#<table class="plugin userdetails">\n#,
qq# <tr>\n#,
qq# <th colspan="#, $DISPLAY_IMAGES ? 4 : 3, qq#">$trans</th>\n#,
}
else
{
- print ' ';
+ print $fh " \n";
}
print $fh qq# </td>\n <td>\n#;
for (my $i = 0; $i < 4; $i++)
{
my $num = $nick_data->{$nick}{'weekdays'}{$day}[$i];
- my $height = sprintf ("%.2f", 95 * $num / $max_weekday);
- my $class = '';
+ my $height = sprintf ("%.2f", 95 * $num / $max_weekdays);
my $img = $V_IMAGES[$i];
print $fh qq# <td class="bar vertical">#,
print $fh qq# </tr>\n#,
qq# </table>\n#;
}
+ else
+ {
+ print $fh " \n";
+ }
print $fh qq# </td>\n <td>\n#;
#longterm
- print $fh qq# \n#;
+ if (@{$nick_data->{$nick}{'longterm'}})
+ {
+ my $num_fields = scalar (@{$nick_data->{$nick}{'longterm'}});
+ my $now_epoch = get_most_recent_time ();
+ my $now_day = int ($now_epoch / 86400);
+ my $last_day;
+
+ my @weekdays = (qw(sun mon tue wed thu fri sat));
+
+ $LongtermDays = $num_fields if ($LongtermDays > $num_fields);
+ $last_day = 1 + $now_day - $LongtermDays;
+
+ print $fh qq# <table class="longterm">\n#,
+ qq# <tr class="bars">\n#;
+
+ for (my $i = $num_fields - $LongtermDays; $i < $num_fields; $i++)
+ {
+ for (my $j = 0; $j < 4; $j++)
+ {
+ my $num = $nick_data->{$nick}{'longterm'}[$i][$j];
+ my $height = sprintf ("%.2f", 95 * $num / $max_longterm);
+ my $img = $V_IMAGES[$j];
+
+ print $fh qq# <td class="bar vertical">#,
+ qq#<img src="$img" alt="" class="first last" style="height: $height\%;" />#,
+ qq#</td>\n#;
+ }
+ }
+
+ print $fh qq# </tr>\n#,
+ qq# <tr class="numeration">\n#;
+
+ for (my $i = 0; $i < $LongtermDays; $i++)
+ {
+ my $epoch = ($last_day + $i) * 86400;
+ my ($day, $wd) = (localtime ($epoch))[3,6];
+ $wd = $weekdays[$wd];
+
+ print $fh qq# <td colspan="4" class="numeration $wd">$day.</td>\n#;
+ }
+
+ print $fh qq# </tr>\n#,
+ qq# </table>\n#;
+ }
+ else
+ {
+ print $fh " \n";
+ }
print $fh qq# </td>\n </tr>\n#;
}
@Onis::Users::EXPORT_OK =
(qw(
- ident_to_name chatter_to_name name_to_ident
+ chatter_to_name
+ name_to_chatter name_to_ident name_to_nick
get_realname get_link get_image
));
@Onis::Users::ISA = ('Exporter');
=cut
our $Users = {};
-our $IdentToName = {};
-our $NameToIdent = {};
-
+our $ChatterToName = {};
+our $NameToChatter = {};
my $VERSION = '$Id$';
print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG);
=over 4
-=item B<ident_to_name> (I<$ident>)
+=item B<chatter_to_name> (I<$chatter>)
-Matches the ident against the configured hostmasks. Uses caching to
-speed up execution. Returns the name or an empty string if not found.
+Passes the ident-part of I<$chatter> to B<ident_to_name>.
=cut
-sub ident_to_name
+sub chatter_to_name
{
- my $ident = shift;
- my $name = '';
+ my $chatter = shift;
+ my $retval = '';
- if (defined ($IdentToName->{$ident}))
+ if (defined ($ChatterToName->{$chatter}))
{
- $name = $IdentToName->{$ident};
+ return ($ChatterToName->{$chatter});
}
- else
+
+ USER: for (keys %$Users)
{
- USER: for (keys (%$Users))
+ my $name = $_;
+ for (@{$Users->{$name}{'host'}})
{
- my $this_name = $_;
- for (@{$Users->{$this_name}{'host'}})
- {
- my $host_re = $_;
+ my $re = $_;
- if ($ident =~ $host_re)
- {
- $name = $this_name;
- last (USER);
- }
+ if ($chatter =~ $re)
+ {
+ $retval = $_;
+ last USER;
}
}
+ }
- if (($::DEBUG & 0x1000) and $name)
- {
- print STDERR $/, __FILE__, ": Host ``$ident'' belongs to ``$name''";
- }
+ if (($::DEBUG & 0x1000) and $retval)
+ {
+ print STDERR $/, __FILE__, ": ``$chatter'' identified as ``$retval''";
}
-
- $IdentToName->{$ident} = $name;
- $NameToIdent->{$name} = $ident if ($name);
- return ($name);
+
+ $ChatterToName->{$chatter} = $retval;
+ $NameToChatter->{$retval} = $chatter if ($retval);
+
+ return ($retval);
}
-=item B<chatter_to_name> (I<$chatter>)
+=item B<name_to_chatter> (I<$name>)
-Passes the ident-part of I<$chatter> to B<ident_to_name>.
+Returns the most recent chatter for I<$name>.
=cut
-sub chatter_to_name
+sub name_to_chatter
{
- my $chatter = shift;
- my ($nick, $ident) = split (m/!/, $chatter);
+ my $name = shift;
- return (ident_to_name ($ident));
+ if (defined ($NameToChatter->{$name}))
+ {
+ return ($NameToChatter->{$name});
+ }
+ else
+ {
+ return ('');
+ }
}
=item B<name_to_ident> (I<$name>)
-Does the reverse of B<ident_to_name>: Returns the most recent association of
-I<$name> to an ident. This function should rarely be needed..
+Returns the most recent ident for I<$name>.
=cut
{
my $name = shift;
- if (defined ($NameToIdent->{$name}))
+ if (defined ($NameToChatter->{$name}))
+ {
+ my $chatter = $NameToChatter->{$name};
+ my ($nick, $ident) = split (m/!/, $chatter);
+
+ return ($ident);
+ }
+ else
+ {
+ return ('');
+ }
+}
+
+=item B<name_to_nick> (I<$name>)
+
+Returns the most recent nick for I<$name>.
+
+=cut
+
+sub name_to_nick
+{
+ my $name = shift;
+
+ if (defined ($NameToChatter->{$name}))
{
- return ($NameToIdent->{$name});
+ my $chatter = $NameToChatter->{$name};
+ my ($nick, $ident) = split (m/!/, $chatter);
+
+ return ($nick);
}
else
{