Skip to content

Instantly share code, notes, and snippets.

@niner
Last active August 29, 2015 14:13
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 niner/cf796b4c1ef70474cad5 to your computer and use it in GitHub Desktop.
Save niner/cf796b4c1ef70474cad5 to your computer and use it in GitHub Desktop.
#!perl6
use Inline::Perl5;
my $p5 = Inline::Perl5.new;
$p5.use('Bot::BasicBot');
class P6Bot does Inline::Perl5::Perl5Parent['Bot::BasicBot'] {
method can($method) {
return 1;
}
method said(%statement) {
self.reply($%statement, "Hullo {%statement<who>}!") if %statement<body> eq 'Hi bot!';
self.reply($%statement, "I'm the first Perl 6 bot based on Bot::BasicBot!") if %statement<body> eq 'bot who are you?';
self.shutdown('leaving...') if %statement<body> eq 'bot quit';
}
method say(*@args) {
$.parent.perl5.invoke('Bot::BasicBot', $.parent.ptr, 'say', self, |@args);
}
}
my $bot = P6Bot.new(
perl5 => $p5,
server => "irc.freenode.org",
port => "6667",
channels => ["#perl6"],
nick => "p6basicbot",
name => "Yet Another Bot",
);
$bot.run();
# vim: ft=perl6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment