diff options
-rw-r--r-- | bot.pl | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -7,8 +7,8 @@ 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 = '#kiffer.de'; |
12 | 12 | ||
13 | POE::Component::IRC->new("francoise"); | 13 | POE::Component::IRC->new("francoise"); |
14 | POE::Session->new ( _start => \&irc_start, | 14 | POE::Session->new ( _start => \&irc_start, |
@@ -133,6 +133,8 @@ sub irc_pub_msg{ | |||
133 | my @words = (split / /, $msg); | 133 | my @words = (split / /, $msg); |
134 | my $w0rds = 0; | 134 | my $w0rds = 0; |
135 | 135 | ||
136 | return if $nick_ eq $current_nick; | ||
137 | |||
136 | #tidy nick and tidy msg from dest nick | 138 | #tidy nick and tidy msg from dest nick |
137 | my $nick = francoise_verifyuser( $nick_, "", 0, $kernel ); | 139 | my $nick = francoise_verifyuser( $nick_, "", 0, $kernel ); |
138 | $msg =~ s/^\S+: +//; | 140 | $msg =~ s/^\S+: +//; |
@@ -176,12 +178,12 @@ sub irc_pub_msg{ | |||
176 | my $thr = join ' ', $dbh->selectrow_array( | 178 | my $thr = join ' ', $dbh->selectrow_array( |
177 | "SELECT trigger, hilfsverb, reply FROM knowledge WHERE trigger = ? ORDER BY RANDOM() LIMIT 1", undef, $msg ); | 179 | "SELECT trigger, hilfsverb, reply FROM knowledge WHERE trigger = ? ORDER BY RANDOM() LIMIT 1", undef, $msg ); |
178 | $thr =~ s/^.*?(?:<reply> )(.*)$/$1/; | 180 | $thr =~ s/^.*?(?:<reply> )(.*)$/$1/; |
181 | $thr =~ s/!who/$nick/g; | ||
179 | $kernel->post( 'francoise', 'privmsg', $channel, $thr ) if $thr; | 182 | $kernel->post( 'francoise', 'privmsg', $channel, $thr ) if $thr; |
180 | } | 183 | } |
181 | 184 | ||
182 | #credit word and line count to user | 185 | #credit word and line count to user |
183 | $dbh->do( "UPDATE users SET lines = lines + 1, words = words + ?, w0rds = w0rds + ?, isaway = false WHERE nick = ?", | 186 | $dbh->do( "UPDATE users SET lines = lines + 1, words = words + ?, w0rds = w0rds + ?, isaway = false WHERE nick = ?", undef, $#words + 1, $w0rds, $nick );; |
184 | undef, $#words + 1, $w0rds, $nick ) if $nick ne $current_nick; | ||
185 | 187 | ||
186 | print "$channel: <$nick> $msg\n"; | 188 | print "$channel: <$nick> $msg\n"; |
187 | } | 189 | } |