Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created April 6, 2013 09:47
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 tadzik/5325584 to your computer and use it in GitHub Desktop.
Save tadzik/5325584 to your computer and use it in GitHub Desktop.
use v6;
use Net::IRC::Bot;
use MuEvent;
role Net::IRC::Bot::MuEvent {
method muevent-run {
self.disconnect;
self.connect;
MuEvent::socket(
socket => $.conn,
poll => 'r',
params => { sock => $.conn },
cb => sub (:$sock) {
my $line = $sock.get or die "Connection error.";
$line ~~ s/<[\n\r]>+$//;
my $event = Net::IRC::Parser::RawEvent.parse($line)
or note("Could not parse the following IRC event: $line.perl()") and return True;
say ~$event if $.debug;
self.dispatch($event);
return True;
}
);
}
}
# vim: ft=perl6 tabstop=4 shiftwidth=4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment