Created
July 6, 2014 18:29
-
-
Save vaskozl/d8e322c21e90877e4f42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
package MyBot; | |
use base qw( Bot::BasicBot ); | |
# the 'said' callback gets called when someone says something in | |
# earshot of the bot. | |
sub said { | |
my ($self, $message) = @_; | |
if ($message->{body}) { | |
# return "$message->{body}" <--------- this works but vvv this does not | |
check($message->{body}, $self); | |
} | |
} | |
#Check shit to know what to reply | |
sub check { | |
my $transcript = $_[0]; | |
my $self = $_[1]; | |
my @think = ( | |
{ | |
cond => sub { "1" == "1" }, | |
action => sub {return "hello"; ;} | |
}, | |
); | |
foreach(@think){ | |
my %deep=%{$_}; | |
if( grep $deep{cond}->($_), $transcript ){$deep{action}->($transcript);} | |
} | |
} | |
# help text for the bot | |
sub help { "I'm annoying, and do nothing useful." } | |
# Create an instance of the bot and start it running. Connect | |
# to the main perl IRC server, and join some channels. | |
MyBot->new( | |
server => 'irc.freenode.net', | |
channels => [ '#islk', '#islk2' ], | |
nick => 'vaskobot', | |
)->run(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment