Created
April 6, 2013 09:47
-
-
Save tadzik/5325584 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
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