From 64c2038041208482671dc49924814a355fc892ab Mon Sep 17 00:00:00 2001 From: kiffer <> Date: Fri, 5 Aug 2005 23:47:17 +0000 Subject: - singular/plural bei zeiten - kein whitespace hinter enforcen - integerwerte bei zeiten --- bot.pl | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/bot.pl b/bot.pl index 4bb7379..4720799 100644 --- a/bot.pl +++ b/bot.pl @@ -7,8 +7,10 @@ use DBI; use POE; use POE::Component::IRC; -my $current_nick = 'francoise'; -my $channel = '#kiffer.de'; +#my $current_nick = 'francoise'; +my $current_nick = 'franzi'; +#my $channel = '#kiffer.de'; +my $channel = "#test"; POE::Component::IRC->new("francoise"); POE::Session->new ( _start => \&irc_start, @@ -205,7 +207,7 @@ sub irc_pub_msg{ #search in our knowledge my $thr = join ' ', $dbh->selectrow_array( "SELECT trigger, hilfsverb, reply FROM knowledge WHERE trigger = ? ORDER BY RANDOM() LIMIT 1", undef, $msg ); - $thr =~ s/^.*?(?: +?)(.*)$/$1/; + $thr =~ s/^.*?(?: *?)(.*)$/$1/; $thr =~ s/!who/$nick/g; $thr =~ s'!date'francoise_date()'eg; $thr =~ s'!time'francoise_time()'eg; @@ -291,21 +293,24 @@ sub francoise_stat { if $msg; my $age = time() - $starttime; - my $secs = $age % 60; - my $mins = ( $age / 60 ) % 3600; - my $hours = ( $age / 3600 ) % 86400; - my $days = $age / 86400; + my $secs = int($age % 60); + my $mins = int(( $age / 60 ) % 3600); + my $hours = int(( $age / 3600 ) % 86400); + my $days = int($age / 86400); my $agestring; if( $age < 60 ) { - $agestring = "$secs Sekunden"; + $agestring = "$secs Sekunde" . ($secs == 1 ? "" : "n"); } elsif( $age < 3600 ) { - $agestring = "$mins Minuten $secs Sekunden"; + $agestring = "$mins Minute" . ($mins == 1 ? "" : "n") . "$secs Sekunde" + . ($secs == 1 ? "" : "n"); } elsif( $age < 86400) { - $agestring = "$hours Stunden $mins Minuten"; + $agestring = "$hours Stunde" . ($hours == 1 ? "" : "n") . " $mins Minute" + . ($mins == 1 ? "" : "n"); } else { - $agestring = "$days Tage $hours Stunden"; + $agestring = "$days Tag" . ($days == 1 ? "" : "e") . " $hours Stunde" . + ($hours == 1 ? "" : "n"); } my ($usercnt) = $dbh->selectrow_array( "SELECT COUNT(*) FROM users" ); -- cgit v1.2.3