diff options
Diffstat (limited to 'bot.pl')
-rw-r--r-- | bot.pl | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -128,7 +128,7 @@ sub irc_quit { | |||
128 | 128 | ||
129 | sub irc_pub_msg{ | 129 | sub irc_pub_msg{ |
130 | my $kernel = $_[KERNEL]; | 130 | my $kernel = $_[KERNEL]; |
131 | my $nick = (split /!/, $_[ARG0])[0]; | 131 | my $nick_ = (split /!/, $_[ARG0])[0]; |
132 | my $channel = $_[ARG1]->[0]; | 132 | my $channel = $_[ARG1]->[0]; |
133 | my $msg = $_[ARG2]; | 133 | my $msg = $_[ARG2]; |
134 | my @words = (split / /, $msg); | 134 | my @words = (split / /, $msg); |
@@ -138,7 +138,19 @@ sub irc_pub_msg{ | |||
138 | &{$commands{ $1 } || \&francoise_donothing } ( $kernel, $channel, $msg ); | 138 | &{$commands{ $1 } || \&francoise_donothing } ( $kernel, $channel, $msg ); |
139 | } | 139 | } |
140 | 140 | ||
141 | $nick = francoise_verifyuser( $nick, "", 0, $kernel ); | 141 | my $nick = francoise_verifyuser( $nick_, "", 0, $kernel ); |
142 | |||
143 | if( $msg =~ /^wo ist (\S+)/i ) { | ||
144 | my $wois_ = $1; | ||
145 | my $wois = ( split /_/, $1 )[0] || $1; | ||
146 | my $sth = $dbh->prepare( "SELECT awaymsg FROM users WHERE nick = '$wois' AND isaway = 'true'"); | ||
147 | $sth->execute(); | ||
148 | if ( my @awaymsg = $sth->fetchrow_array ) { | ||
149 | $kernel->post( 'irc_client', 'privmsg', $channel, "$wois_ ist $awaymsg[0]" ); | ||
150 | } else { | ||
151 | $kernel->post( 'irc_client', 'privmsg', $channel, "Ich weiss nicht, wo $wois_ ist." ); | ||
152 | } | ||
153 | } | ||
142 | 154 | ||
143 | if( $nick ne $current_nick ) { | 155 | if( $nick ne $current_nick ) { |
144 | $dbh->do( "UPDATE users SET lines = lines + 1, words = words + $numwords + 1 WHERE nick = '$nick'" ); | 156 | $dbh->do( "UPDATE users SET lines = lines + 1, words = words + $numwords + 1 WHERE nick = '$nick'" ); |
@@ -179,7 +191,7 @@ sub francoise_verifyuser { | |||
179 | if( $host ) { | 191 | if( $host ) { |
180 | my ($cnt) = $dbh->selectrow_array( "SELECT COUNT(*) FROM users WHERE nick='$nick'" ); | 192 | my ($cnt) = $dbh->selectrow_array( "SELECT COUNT(*) FROM users WHERE nick='$nick'" ); |
181 | if ( $cnt == 0 ) { | 193 | if ( $cnt == 0 ) { |
182 | $dbh->do( "INSERT INTO users(id, nick, words, lines, lastlogin, lasthost) VALUES ( '$nick', '$nick', 0, 0, now(), '$host' )"); | 194 | $dbh->do( "INSERT INTO users(id, nick, words, lines, lastlogin, lasthost) VALUES ( '', '$nick', 0, 0, now(), '$host' )"); |
183 | } else { | 195 | } else { |
184 | $dbh->do( "UPDATE users SET lasthost = '$host'" . ( $updtime ? ", lastlogin = now()" : "" ) . " WHERE nick = '$nick'" ); | 196 | $dbh->do( "UPDATE users SET lasthost = '$host'" . ( $updtime ? ", lastlogin = now()" : "" ) . " WHERE nick = '$nick'" ); |
185 | } | 197 | } |