Permalink
Browse files

Merge pull request #4 from moritz/master

Various improvements
  • Loading branch information...
2 parents 4c14a2d + 9c45729 commit edc4a48840b520eb8bdaac0a813564b175a078c6 @TiMBuS committed Feb 24, 2013
Showing with 17 additions and 6 deletions.
  1. +4 −3 lib/Net/IRC/Bot.pm
  2. +10 −0 lib/Net/IRC/Event.pm
  3. +1 −1 lib/Net/IRC/Handlers/Default.pm
  4. +2 −2 lib/Net/IRC/Modules/Autoident.pm
View
@@ -79,11 +79,12 @@ class Net::IRC::Bot {
self!connect;
loop {
#XXX: Support for timed events?
- my $line = $conn.get.encode('utf-8').decode('utf8')
+ my $line = $conn.get
or die "Connection error.";
+ $line ~~ s/<[\n\r]>+$//;
my $event = Net::IRC::Parser::RawEvent.parse($line)
- or $*ERR.say("Could not parse the following IRC event: $line") and next;
+ or $*ERR.say("Could not parse the following IRC event: $line.perl()") and next;
say ~$event if $.debug;
self!dispatch($event);
@@ -94,7 +95,7 @@ class Net::IRC::Bot {
#Make an event object and fill it as much as we can.
#XXX: Should I just use a single cached Event to save memory?
my $who = ($raw<user> || $raw<server> || "");
- $who does role { method Str { self<nick>.Str || self<host>.Str } }
+ $who does role { method Str { (self<nick> // self<host> ).Str } }
#XXX Stupid workaround.
my $l = $raw<params>.elems;
View
@@ -44,6 +44,16 @@ class Net::IRC::Event {
method Str {
$.what ?? ~$.what !! $.raw;
}
+
+ multi method gist(Net::IRC::Event:D:) {
+ join "\n",
+ "Event($.command)",
+ (" where: $.where" if $.where),
+ (" what: $.what" if $.what),
+ (" who: $.who" if $.who),
+ " raw: $.raw",
+ ;
+ }
}
# vim: ft=perl6 expandtab sw=4
@@ -36,7 +36,7 @@ class Net::IRC::Handlers::Default {
#Autojoin method. Handy.
multi method connected($ev) {
- $ev.conn.sendln("JOIN $_") for $ev.state<autojoin>;
+ $ev.conn.sendln("JOIN $_") for $ev.state<autojoin>.list;
}
@@ -2,9 +2,9 @@ use v6;
module Net::IRC::Modules::Autoident;
class Net::IRC::Modules::Autoident {
- has $password = die "Need to tell Autoident your password if you want it to work!";
+ has $.password = die "Need to tell Autoident your password if you want it to work!";
multi method connected($ev) {
say "Identifying with nickserv..";
- $ev.conn.sendln("NS IDENTIFY $password");
+ $ev.conn.sendln("NS IDENTIFY $.password");
}
}

0 comments on commit edc4a48

Please sign in to comment.