diff options
Diffstat (limited to 'bot.pl')
-rw-r--r-- | bot.pl | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -7,7 +7,7 @@ use DBI; | |||
7 | use POE; | 7 | use POE; |
8 | use POE::Component::IRC; | 8 | use POE::Component::IRC; |
9 | 9 | ||
10 | my $current_nick = "francoise_"; | 10 | my $current_nick = 'francoise_'; |
11 | my $channel = '#test'; | 11 | my $channel = '#test'; |
12 | 12 | ||
13 | POE::Component::IRC->new("francoise"); | 13 | POE::Component::IRC->new("francoise"); |
@@ -311,8 +311,33 @@ sub francoise_alias{ | |||
311 | my ($kernel, $dest, $msg ) = @_; | 311 | my ($kernel, $dest, $msg ) = @_; |
312 | 312 | ||
313 | my ($nick, $alias) = (split / /, $msg ); | 313 | my ($nick, $alias) = (split / /, $msg ); |
314 | print "$nick is also $alias \n"; | ||
315 | 314 | ||
315 | my $sth = $dbh->prepare( "SELECT nick FROM aliases WHERE alias = ?" ); | ||
316 | $sth->execute( $nick ); | ||
317 | if( my ($tmp) = $sth->fetchrow_array ) { | ||
318 | $alias = $nick; $nick = $tmp; | ||
319 | } | ||
320 | |||
321 | $sth = $dbh->prepare( "SELECT COUNT(*) FROM aliases WHERE nick = ? AND alias = ?" ); | ||
322 | $sth->execute( $nick, $alias); | ||
323 | return if( ($sth->fetchrow_array)[0] > 0 ); | ||
324 | |||
325 | $sth = $dbh->prepare( "SELECT words, lines FROM users WHERE nick = ?"); | ||
326 | $sth->execute($nick); my @userrow = $sth->fetchrow_array; | ||
327 | $sth->execute($alias); my @aliasrow = $sth->fetchrow_array; | ||
328 | |||
329 | print "@userrow @aliasrow \n"; | ||
330 | |||
331 | if( @userrow && @aliasrow ) { | ||
332 | $sth = $dbh->prepare( "UPDATE users SET isaway = false, words = ?, lines = ? WHERE nick = ?" ); | ||
333 | $sth->execute( $userrow[0]+$aliasrow[0], $userrow[1]+$aliasrow[1], $nick ); | ||
334 | |||
335 | $sth = $dbh->prepare( "INSERT INTO aliases ( nick, alias ) VALUES ( ?, ? )" ); | ||
336 | $sth->execute($nick, $alias); | ||
337 | |||
338 | $sth = $dbh->prepare( "DELETE FROM users WHERE nick = ?" ); | ||
339 | $sth->execute( $alias ); | ||
340 | } | ||
316 | } | 341 | } |
317 | 342 | ||
318 | sub francoise_topten0r { | 343 | sub francoise_topten0r { |