Skip to content

Instantly share code, notes, and snippets.

@Altreus
Forked from vaskozl/test.pl
Last active August 29, 2015 14:03
Show Gist options
  • Save Altreus/2a34ba2768330ef1c18a to your computer and use it in GitHub Desktop.
Save Altreus/2a34ba2768330ef1c18a 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
$self->check($message->{body});
}
}
#Check shit to know what to reply
sub check {
my $self = shift;
my $transcript = $_[0];
my @think = (
{
cond => sub { 1 },
action => sub {
return "hello";
system q(~/Dropbox/speech/tts.sh "Hello, I\'m Luna, how can I help you?");
}
},
);
foreach my $action (@think) {
if( $action->{cond}->($transcript) ){
return $action->{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