Permalink
Browse files

Added some patchwork to make this work with nom

  • Loading branch information...
Jarrod
Jarrod committed Oct 22, 2011
1 parent 47c259e commit 1e6a243472298b46994d0ae2c095f2344d8c7942
View
@@ -53,6 +53,7 @@ class Net::IRC::Bot {
but role {
method sendln(Str $string){self.send($string~"\c13\c10")}
};
+ say 'conn made';
#Send PASS if needed
$conn.sendln("PASS $password") if $password;
@@ -62,6 +63,7 @@ class Net::IRC::Bot {
#USER Parameters: <username> <hostname> <servername> <realname>
$conn.sendln("NICK $nick");
$conn.sendln("USER $username abc.xyz.net $server :$realname");
+ say 'sent thing to srvr';
%state<connected> = True;
}
@@ -81,28 +83,31 @@ class Net::IRC::Bot {
my $line = $conn.get
or die "Connection error.";
- my $event = RawEvent.parse($line)
+ my $event = Net::IRC::Parser::RawEvent.parse($line)
or $*ERR.say("Could not parse the following IRC event: $line") and next;
say ~$event if $debug;
self!dispatch($event);
}
}
- multi method !dispatch($raw) {
+ method !dispatch($raw) {
#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> || self<host> } };
+ #XXX Stupid workaround.
+ my $l = $raw<params>.elems;
+
my $event = Net::IRC::Event.new(
:raw($raw),
:command(~$raw<command>),
:conn($conn),
:state(%state),
:who($who),
:where(~$raw<params>[0]),
- :what(~$raw<params>[*-1]),
+ :what(~$raw<params>[$l ?? $l-1 !! 0]),
);
View
@@ -25,7 +25,7 @@ class Net::IRC::Event {
#Break up the line using a nearby space if possible.
my $index = $line.rindex(" ", $maxlen) || $maxlen;
$.conn.sendln($prepend~$line.substr(0, $index));
- $line := $line.substr($index+1);
+ $line = $line.substr($index+1);
}
$.conn.sendln($prepend~$line);
}
@@ -1,7 +1,7 @@
use v6;
-module Modules::ACME;
+module Net::IRC::Modules::ACME;
-class Eightball {
+class Net::IRC::Modules::ACME::Eightball {
my @replies = "Probably not", "Nope", "Never", "Not a chance", "Doubt it", "No",
"Answer hazy.. Oh wait there it is. It's a no.", "Yes.. Haha just kidding. No.",
"No.", "Aww hell naw";
@@ -11,7 +11,7 @@ class Eightball {
}
}
-class Unsmith {
+class Net::IRC::Modules::ACME::Unsmith {
has @replies = open('Net/IRC/Modules/unsmith').lines;
my regex sad {
[ ^|\s ]
@@ -1,7 +1,7 @@
use v6;
-module Modules::Autoident;
+module Net::IRC::Modules::Autoident;
-class Autoident {
+class Net::IRC::Modules::Autoident {
has $password = die "Need no tell Autoident your password if you want it to work!";
multi method connected($ev) {
say "Identifying with nickserv..";
@@ -1,5 +1,5 @@
use v6;
-class Tell {
+class Net::IRC::Modules::Tell {
class Message {
has $.sender;
has $.message;
@@ -65,7 +65,7 @@ class Tell {
$hours ?? (", $hours hour" ~
($hours != 1 ?? 's' !! '') ) !! '';
}
- dafault {
+ default {
my $days = ($elapsed / 60 / 60 / 24).round;
return "$days day"~($days != 1 ?? 's' !! '');
}
View
@@ -1,35 +1,33 @@
use v6;
-class Net::IRC::Parser {
- grammar RawEvent {
- token TOP {
- ^
- [':' [<user>|<server=host>] <.space> || <?>]
- <command>
- [ <.space>+ [':'$<params>=(.*)$ || $<params>=<-space>+] ]*
- $
- }
+module Net::IRC::Parser;
+grammar RawEvent {
+ token TOP {
+ ^
+ [':' [<user>|<server=host>] <.space> || <?>]
+ <command>
+ [ <.space>+ [':'$<params>=(.*)$ || $<params>=<-space>+] ]*
+ $
+ }
- token user {
- $<nick>=<-[:!]>+ '!' $<ident>=<-[@]>+ '@' <host>
- }
+ token user {
+ $<nick>=<-[:!]>+ '!' $<ident>=<-[@]>+ '@' <host>
+ }
- token host {
- #[ <-space - [. $ @ !]>+ ] ** '.'
-
- #Due to some IRC servers/services allowing anything as a host format,
- #I've decided to define a 'host' as 'anything but a space'. Bah.
- <-space>+
- }
+ token host {
+ #[ <-space - [. $ @ !]>+ ] ** '.'
+
+ #Due to some IRC servers/services allowing anything as a host format,
+ #I've decided to define a 'host' as 'anything but a space'. Bah.
+ <-space>+
+ }
- token command {
- <.alpha>+ | \d\d\d
- }
+ token command {
+ <.alpha>+ | \d\d\d
+ }
- token params {
- [ ':'.*$ | <-space>+ ]
- }
+ token params {
+ [ ':'.*$ | <-space>+ ]
}
-
-
}
+

0 comments on commit 1e6a243

Please sign in to comment.