summaryrefslogtreecommitdiff
path: root/bot.pl
diff options
context:
space:
mode:
Diffstat (limited to 'bot.pl')
-rw-r--r--bot.pl29
1 files changed, 27 insertions, 2 deletions
diff --git a/bot.pl b/bot.pl
index 2d37864..0c0a426 100644
--- a/bot.pl
+++ b/bot.pl
@@ -7,7 +7,7 @@ use DBI;
7use POE; 7use POE;
8use POE::Component::IRC; 8use POE::Component::IRC;
9 9
10my $current_nick = "francoise_"; 10my $current_nick = 'francoise_';
11my $channel = '#test'; 11my $channel = '#test';
12 12
13POE::Component::IRC->new("francoise"); 13POE::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
318sub francoise_topten0r { 343sub francoise_topten0r {