Skip to content
Browse files

Split out the parser code into its own module. The idea is so others …

…can use it for their own IRC stuff without needing the entire ::Bot module.

I also fixed a confusing typo in the readme. Thanks daniel-s!
  • Loading branch information...
1 parent 6c62311 commit 268621afac789d5b7093dfd297608bc60c33e38f Jarrod committed Jun 12, 2011
Showing with 39 additions and 32 deletions.
  1. +3 −3 README.pod
  2. +1 −29 lib/Net/IRC/Bot.pm
  3. +35 −0 lib/Net/IRC/Parser.pm
View
6 README.pod
@@ -25,11 +25,11 @@ Elegant. Simple. Probably compiles.
Net::IRC::Bot.new(
- nick => 'KickMe',
- server => 'irc.freenode.net',
+ nick => 'KickMe',
+ server => 'irc.freenode.net',
channels => <#bottest>,
- modules = (AnnoyUsers.new(), Autoident.new(password => 'nspassw0rd')),
+ modules => (AnnoyUsers.new(), Autoident.new(password => 'nspassw0rd')),
).run;
=head1 Description
View
30 lib/Net/IRC/Bot.pm
@@ -1,5 +1,6 @@
use v6;
use Net::IRC::DefaultHandlers;
+use Net::IRC::Parser;
use Net::IRC::Event;
class Net::IRC::Bot {
@@ -70,35 +71,6 @@ class Net::IRC::Bot {
}
}
- grammar RawEvent {
- token TOP {
- ^
- [':' [<user>|<server=host>] <.space> || <?>]
- <command>
- [ <.space>+ [':'$<params>=(.*)$ || $<params>=<-space>+] ]*
- $
- }
-
- 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 command {
- <.alpha>+ | \d\d\d
- }
-
- token params {
- [ ':'.*$ | <-space>+ ]
- }
- }
method run() {
self!disconnect;
View
35 lib/Net/IRC/Parser.pm
@@ -0,0 +1,35 @@
+use v6;
+
+class Net::IRC::Parser {
+ grammar RawEvent {
+ token TOP {
+ ^
+ [':' [<user>|<server=host>] <.space> || <?>]
+ <command>
+ [ <.space>+ [':'$<params>=(.*)$ || $<params>=<-space>+] ]*
+ $
+ }
+
+ 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 command {
+ <.alpha>+ | \d\d\d
+ }
+
+ token params {
+ [ ':'.*$ | <-space>+ ]
+ }
+ }
+
+
+}

0 comments on commit 268621a

Please sign in to comment.
Something went wrong with that request. Please try again.