summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot.pl27
1 files 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;
7use POE; 7use POE;
8use POE::Component::IRC; 8use POE::Component::IRC;
9 9
10my $current_nick = 'francoise'; 10#my $current_nick = 'francoise';
11my $channel = '#kiffer.de'; 11my $current_nick = 'franzi';
12#my $channel = '#kiffer.de';
13my $channel = "#test";
12 14
13POE::Component::IRC->new("francoise"); 15POE::Component::IRC->new("francoise");
14POE::Session->new ( _start => \&irc_start, 16POE::Session->new ( _start => \&irc_start,
@@ -205,7 +207,7 @@ sub irc_pub_msg{
205 #search in our knowledge 207 #search in our knowledge
206 my $thr = join ' ', $dbh->selectrow_array( 208 my $thr = join ' ', $dbh->selectrow_array(
207 "SELECT trigger, hilfsverb, reply FROM knowledge WHERE trigger = ? ORDER BY RANDOM() LIMIT 1", undef, $msg ); 209 "SELECT trigger, hilfsverb, reply FROM knowledge WHERE trigger = ? ORDER BY RANDOM() LIMIT 1", undef, $msg );
208 $thr =~ s/^.*?(?:<reply> +?)(.*)$/$1/; 210 $thr =~ s/^.*?(?:<reply> *?)(.*)$/$1/;
209 $thr =~ s/!who/$nick/g; 211 $thr =~ s/!who/$nick/g;
210 $thr =~ s'!date'francoise_date()'eg; 212 $thr =~ s'!date'francoise_date()'eg;
211 $thr =~ s'!time'francoise_time()'eg; 213 $thr =~ s'!time'francoise_time()'eg;
@@ -291,21 +293,24 @@ sub francoise_stat {
291 if $msg; 293 if $msg;
292 294
293 my $age = time() - $starttime; 295 my $age = time() - $starttime;
294 my $secs = $age % 60; 296 my $secs = int($age % 60);
295 my $mins = ( $age / 60 ) % 3600; 297 my $mins = int(( $age / 60 ) % 3600);
296 my $hours = ( $age / 3600 ) % 86400; 298 my $hours = int(( $age / 3600 ) % 86400);
297 my $days = $age / 86400; 299 my $days = int($age / 86400);
298 300
299 my $agestring; 301 my $agestring;
300 302
301 if( $age < 60 ) { 303 if( $age < 60 ) {
302 $agestring = "$secs Sekunden"; 304 $agestring = "$secs Sekunde" . ($secs == 1 ? "" : "n");
303 } elsif( $age < 3600 ) { 305 } elsif( $age < 3600 ) {
304 $agestring = "$mins Minuten $secs Sekunden"; 306 $agestring = "$mins Minute" . ($mins == 1 ? "" : "n") . "$secs Sekunde"
307 . ($secs == 1 ? "" : "n");
305 } elsif( $age < 86400) { 308 } elsif( $age < 86400) {
306 $agestring = "$hours Stunden $mins Minuten"; 309 $agestring = "$hours Stunde" . ($hours == 1 ? "" : "n") . " $mins Minute"
310 . ($mins == 1 ? "" : "n");
307 } else { 311 } else {
308 $agestring = "$days Tage $hours Stunden"; 312 $agestring = "$days Tag" . ($days == 1 ? "" : "e") . " $hours Stunde" .
313 ($hours == 1 ? "" : "n");
309 } 314 }
310 315
311 my ($usercnt) = $dbh->selectrow_array( "SELECT COUNT(*) FROM users" ); 316 my ($usercnt) = $dbh->selectrow_array( "SELECT COUNT(*) FROM users" );