Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 92 lines (61 sloc) 2.552 kb
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
1 =head1 Net::IRC
2
1eaae4bd » Jarrod
2010-12-16 Fixed up the parser. Made it a tad more error tolerant (freenodes ser…
3 Elegant. Simple. Probably compiles.
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
4
5 =head1 Synopsis
6
7 use Net::IRC::Bot;
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
8 use Modules::Autoident;
9
e9ff58fd » Jarrod
2010-07-29 Made a few changes, experimented with some failed branches. Decided o…
10 class AnnoyUsers does ExtraAnnoying {
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
11 #Will be called when the bot gets a join event
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
12 multi method joined ($e) {
13 $e.reply("Hi there, {$e.who}!");
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
14 }
15 }
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
16
17 #Roles can let you break up large event handler modules into smaller ones.
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
18 role ExtraAnnoying {
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
19 #Magical type constraints only let this event be called when $e.who is an enemy
20 multi method said ($e where {.who ~~ %enemies}) {
21 $e.reply($e.msg); #Parrot back what was said;
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
22 }
23 }
24
e9ff58fd » Jarrod
2010-07-29 Made a few changes, experimented with some failed branches. Decided o…
25
26 Net::IRC::Bot.new(
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
27 nick => 'KickMe',
28 server => 'irc.freenode.net',
29 channels => <#bottest>,
e9ff58fd » Jarrod
2010-07-29 Made a few changes, experimented with some failed branches. Decided o…
30
0ff00b70 » Jarrod
2010-08-22 Updated readme.
31 modules = (AnnoyUsers.new(), Autoident.new(password => 'nspassw0rd')),
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
32 ).run;
33
34 =head1 Description
35
36 Its an IRC Bot framework! Theres not much else to it.
66ead3f1 » Jarrod
2010-12-13 Polished up the readme a bit.
37 It's currently in active development, but it is mostly stable until perl 6 implements
38 either threads or async I/O so it can work correctly as a bot (timed events and things
39 that block the runtime are not possible yet.)
40
41 The framework makes extensive use of the added features perl 6 provides, and is an
42 excellent example of how concise and powerful the language is... With emphasis on
43 concise:- The core code is only about 350 lines!
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
44
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
45 =head1 Methods and Attributes
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
46
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
47 Net::IRC::Bot only really has one needed method: run(). Everything else is setup using
48 parameters to new()
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
49
50 List of attributes + their defaults:
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
51
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
52 $nick = "Rakudobot";
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
53
66ead3f1 » Jarrod
2010-12-13 Polished up the readme a bit.
54 @altnicks = $nick Z~ ("_","__",^10);
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
55
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
56 $username = "Clunky";
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
57
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
58 $realname = '$@%# yeah, perl 6!';
59
60 $server = "irc.perl.org";
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
61
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
62 $port = 6667;
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
63
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
64 $password;
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
65
66ead3f1 » Jarrod
2010-12-13 Polished up the readme a bit.
66 @autojoin = ["#bottest"];
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
67
68 $autoreconnect = False;
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
69
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
70 $throttle = False;
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
71
66ead3f1 » Jarrod
2010-12-13 Polished up the readme a bit.
72 @modules;
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
73
74 =head2 Callbacks
75
66ead3f1 » Jarrod
2010-12-13 Polished up the readme a bit.
76 Callbacks are event handlers created by you, the bot maker. They are dispatched to by
77 name when an appropriate IRC event is fired.
4ad750e3 » Jarrod
2010-08-10 Just some readme fixes, and apparently I changed Event.pm
78
66ead3f1 » Jarrod
2010-12-13 Polished up the readme a bit.
79 There are currently six 'main' types of events: C<said>, C<acted>, C<joined>,
80 C<noticed>, C<nickchanged> and C<connected>. They will be called with a
81 Net::IRC::Event object containing every detail possible about the event. [Details to
82 come soon]
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
83
66ead3f1 » Jarrod
2010-12-13 Polished up the readme a bit.
84 For any event that doesn't fit into the above category, you will need to set up a raw
85 event handler. Raw handlers begin with 'irc_' and won't have their Event objects
86 properly filled [TODO: List what will be filled]
87 The method C<irc_433> for example, will be called when ERR_NICKNAMEINUSE is thrown.
88 C<irc_privmsg> will be just like C<said>, except it will be called first.
3037e97c » Jarrod
2010-07-25 Added a readme, fixed up example bot.
89
90 =head2 Helper methods
91
c3eba57d » Jarrod
2010-08-10 Lots of foxes. I really cotta commit more often.
92 say, act, send_ctcp
Something went wrong with that request. Please try again.