Skip to content

Instantly share code, notes, and snippets.

@vaskozl
Created July 6, 2014 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaskozl/d8e322c21e90877e4f42 to your computer and use it in GitHub Desktop.
Save vaskozl/d8e322c21e90877e4f42 to your computer and use it in GitHub Desktop.
#!/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