From 1feabba6b1d8107296d2494bfc0610d4a2e1361a Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sat, 23 Jul 2005 18:29:51 +0000 Subject: kann so ein wenig awaymsg lookupen --- bot.pl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bot.pl b/bot.pl index 9f09cbd..6548aac 100644 --- a/bot.pl +++ b/bot.pl @@ -128,7 +128,7 @@ sub irc_quit { sub irc_pub_msg{ my $kernel = $_[KERNEL]; - my $nick = (split /!/, $_[ARG0])[0]; + my $nick_ = (split /!/, $_[ARG0])[0]; my $channel = $_[ARG1]->[0]; my $msg = $_[ARG2]; my @words = (split / /, $msg); @@ -138,7 +138,19 @@ sub irc_pub_msg{ &{$commands{ $1 } || \&francoise_donothing } ( $kernel, $channel, $msg ); } - $nick = francoise_verifyuser( $nick, "", 0, $kernel ); + my $nick = francoise_verifyuser( $nick_, "", 0, $kernel ); + + if( $msg =~ /^wo ist (\S+)/i ) { + my $wois_ = $1; + my $wois = ( split /_/, $1 )[0] || $1; + my $sth = $dbh->prepare( "SELECT awaymsg FROM users WHERE nick = '$wois' AND isaway = 'true'"); + $sth->execute(); + if ( my @awaymsg = $sth->fetchrow_array ) { + $kernel->post( 'irc_client', 'privmsg', $channel, "$wois_ ist $awaymsg[0]" ); + } else { + $kernel->post( 'irc_client', 'privmsg', $channel, "Ich weiss nicht, wo $wois_ ist." ); + } + } if( $nick ne $current_nick ) { $dbh->do( "UPDATE users SET lines = lines + 1, words = words + $numwords + 1 WHERE nick = '$nick'" ); @@ -179,7 +191,7 @@ sub francoise_verifyuser { if( $host ) { my ($cnt) = $dbh->selectrow_array( "SELECT COUNT(*) FROM users WHERE nick='$nick'" ); if ( $cnt == 0 ) { - $dbh->do( "INSERT INTO users(id, nick, words, lines, lastlogin, lasthost) VALUES ( '$nick', '$nick', 0, 0, now(), '$host' )"); + $dbh->do( "INSERT INTO users(id, nick, words, lines, lastlogin, lasthost) VALUES ( '', '$nick', 0, 0, now(), '$host' )"); } else { $dbh->do( "UPDATE users SET lasthost = '$host'" . ( $updtime ? ", lastlogin = now()" : "" ) . " WHERE nick = '$nick'" ); } -- cgit v1.2.3