1POE::Component::IRC(3)User Contributed Perl DocumentationPOE::Component::IRC(3)
2
3
4
6 POE::Component::IRC - a fully event-driven IRC client module.
7
9 # A simple Rot13 'encryption' bot
10
11 use strict;
12 use warnings;
13 use POE qw(Component::IRC);
14
15 my $nickname = 'Flibble' . $$;
16 my $ircname = 'Flibble the Sailor Bot';
17 my $ircserver = 'irc.blahblahblah.irc';
18 my $port = 6667;
19
20 my @channels = ( '#Blah', '#Foo', '#Bar' );
21
22 # We create a new PoCo-IRC object and component.
23 my $irc = POE::Component::IRC->spawn(
24 nick => $nickname,
25 server => $ircserver,
26 port => $port,
27 ircname => $ircname,
28 ) or die "Oh noooo! $!";
29
30 POE::Session->create(
31 package_states => [
32 'main' => [ qw(_default _start irc_001 irc_public) ],
33 ],
34 heap => { irc => $irc },
35 );
36
37 $poe_kernel->run();
38 exit 0;
39
40 sub _start {
41 my ($kernel,$heap) = @_[KERNEL,HEAP];
42
43 # We get the session ID of the component from the object
44 # and register and connect to the specified server.
45 my $irc_session = $heap->{irc}->session_id();
46 $kernel->post( $irc_session => register => 'all' );
47 $kernel->post( $irc_session => connect => { } );
48 undef;
49 }
50
51 sub irc_001 {
52 my ($kernel,$sender) = @_[KERNEL,SENDER];
53
54 # Get the component's object at any time by accessing the heap of
55 # the SENDER
56 my $poco_object = $sender->get_heap();
57 print "Connected to ", $poco_object->server_name(), "\n";
58
59 # In any irc_* events SENDER will be the PoCo-IRC session
60 $kernel->post( $sender => join => $_ ) for @channels;
61 undef;
62 }
63
64 sub irc_public {
65 my ($kernel,$sender,$who,$where,$what) = @_[KERNEL,SENDER,ARG0,ARG1,ARG2];
66 my $nick = ( split /!/, $who )[0];
67 my $channel = $where->[0];
68
69 if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) {
70 $rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M];
71 $kernel->post( $sender => privmsg => $channel => "$nick: $rot13" );
72 }
73 undef;
74 }
75
76 # We registered for all events, this will produce some debug info.
77 sub _default {
78 my ($event, $args) = @_[ARG0 .. $#_];
79 my @output = ( "$event: " );
80
81 foreach my $arg ( @$args ) {
82 if ( ref($arg) eq 'ARRAY' ) {
83 push( @output, "[" . join(" ,", @$arg ) . "]" );
84 } else {
85 push ( @output, "'$arg'" );
86 }
87 }
88 print STDOUT join ' ', @output, "\n";
89 return 0;
90 }
91
92 # A Multiple Network Rot13 'encryption' bot
93
94 use strict;
95 use warnings;
96 use POE qw(Component::IRC);
97
98 my $nickname = 'Flibble' . $$;
99 my $ircname = 'Flibble the Sailor Bot';
100 my $port = 6667;
101
102 my $settings = {
103 'server1.irc' => { port => 6667, channels => [ '#Foo' ], },
104 'server2.irc' => { port => 6668, channels => [ '#Bar' ], },
105 'server3.irc' => { port => 7001, channels => [ '#Baa' ], },
106 };
107
108 # We create a new PoCo-IRC objects and components.
109 foreach my $server ( keys %{ $settings } ) {
110 POE::Component::IRC->spawn(
111 alias => $server,
112 nick => $nickname,
113 ircname => $ircname,
114 );
115 }
116
117 POE::Session->create(
118 package_states => [
119 'main' => [ qw(_default _start irc_registered irc_001 irc_public) ],
120 ],
121 heap => { config => $settings },
122 );
123
124 $poe_kernel->run();
125 exit 0;
126
127 sub _start {
128 my ($kernel,$session) = @_[KERNEL,SESSION];
129
130 # Send a POCOIRC_REGISTER signal to all poco-ircs
131 $kernel->signal( $kernel, 'POCOIRC_REGISTER', $session->ID(), 'all' );
132
133 undef;
134 }
135
136 # We'll get one of these from each PoCo-IRC that we spawned above.
137 sub irc_registered {
138 my ($kernel,$heap,$sender,$irc_object) = @_[KERNEL,HEAP,SENDER,ARG0];
139
140 my $alias = $irc_object->session_alias();
141
142 my %conn_hash = (
143 server => $alias,
144 port => $heap->{config}->{ $alias }->{port},
145 );
146
147 # In any irc_* events SENDER will be the PoCo-IRC session
148 $kernel->post( $sender, 'connect', \%conn_hash );
149
150 undef;
151 }
152
153 sub irc_001 {
154 my ($kernel,$heap,$sender) = @_[KERNEL,HEAP,SENDER];
155
156 # Get the component's object at any time by accessing the heap of
157 # the SENDER
158 my $poco_object = $sender->get_heap();
159 print "Connected to ", $poco_object->server_name(), "\n";
160
161 my $alias = $poco_object->session_alias();
162 my @channels = @{ $heap->{config}->{ $alias }->{channels} };
163
164 $kernel->post( $sender => join => $_ ) for @channels;
165
166 undef;
167 }
168
169 sub irc_public {
170 my ($kernel,$sender,$who,$where,$what) = @_[KERNEL,SENDER,ARG0,ARG1,ARG2];
171 my $nick = ( split /!/, $who )[0];
172 my $channel = $where->[0];
173
174 if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) {
175 $rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M];
176 $kernel->post( $sender => privmsg => $channel => "$nick: $rot13" );
177 }
178
179 if ( $what =~ /^!bot_quit$/ ) {
180 # Someone has told us to die =[
181 $kernel->signal( $kernel, 'POCOIRC_SHUTDOWN', "See you loosers" );
182 }
183 undef;
184 }
185
186 # We registered for all events, this will produce some debug info.
187 sub _default {
188 my ($event, $args) = @_[ARG0 .. $#_];
189 my @output = ( "$event: " );
190
191 foreach my $arg ( @$args ) {
192 if ( ref($arg) eq 'ARRAY' ) {
193 push( @output, "[" . join(" ,", @$arg ) . "]" );
194 } else {
195 push ( @output, "'$arg'" );
196 }
197 }
198 print STDOUT join ' ', @output, "\n";
199 return 0;
200 }
201
203 POE::Component::IRC is a POE component (who'd have guessed?) which acts
204 as an easily controllable IRC client for your other POE components and
205 sessions. You create an IRC component and tell it what events your ses‐
206 sion cares about and where to connect to, and it sends back interesting
207 IRC events when they happen. You make the client do things by sending
208 it events. That's all there is to it. Cool, no?
209
210 [Note that using this module requires some familiarity with the details
211 of the IRC protocol. I'd advise you to read up on the gory details of
212 RFC 1459 <http://www.faqs.org/rfcs/rfc1459.html> before you get
213 started. Keep the list of server numeric codes handy while you program.
214 Needless to say, you'll also need a good working knowledge of POE, or
215 this document will be of very little use to you.]
216
217 The POE::Component::IRC distribution has a docs/ folder with a collec‐
218 tion of salient documentation including the pertinent RFCs.
219
220 POE::Component::IRC consists of a POE::Session that manages the IRC
221 connection and dispatches 'irc_' prefixed events to interested sessions
222 and an object that can be used to access additional information using
223 methods.
224
225 Sessions register their interest in receiving 'irc_' events by sending
226 'register' to the component. One would usually do this in your _start
227 handler. Your session will continue to receive events until you 'unreg‐
228 ister'. The component will continue to stay around until you tell it
229 not to with 'shutdown'.
230
231 The SYNOPSIS demonstrates a fairly basic bot.
232
234 Included with POE::Component::IRC are a number of useful subclasses. As
235 they are subclasses they support all the methods, etc. documented here
236 and have additional methods and quirks which are documented separately:
237
238 POE::Component::IRC::State
239 POE::Component::IRC::State provides all the functionality of
240 POE::Component::IRC but also tracks IRC state entities such as
241 nicks and channels.
242
243 POE::Component::IRC::Qnet
244 POE::Component::IRC::Qnet is POE::Component::IRC tweaked for use on
245 Quakenet IRC network.
246
247 POE::Component::IRC::Qnet::State
248 POE::Component::IRC::Qnet::State is a tweaked version of POE::Com‐
249 ponent::IRC::State for use on Quakenet IRC network.
250
252 As of 3.7, PoCo-IRC sports a plugin system. The documentation for it
253 can be read by looking at POE::Component::IRC::Plugin. That is not a
254 subclass, just a placeholder for documentation!
255
256 A number of useful plugins have made their way into the core distribu‐
257 tion:
258
259 POE::Component::IRC::Plugin::Connector
260 Glues an irc bot to an IRC network, ie. deals with maintaining ircd
261 connections.
262
263 POE::Component::IRC::Plugin::BotTraffic
264 Under normal circumstances irc bots do not normal the msgs and pub‐
265 lic msgs that they generate themselves. This plugin enables you to
266 handle those events.
267
268 POE::Component::IRC::Plugin::BotAddressed
269 Generates 'irc_bot_addressed' events whenever someone addresses
270 your bot by name in a channel.
271
272 POE::Component::IRC::Plugin::Console
273 See inside the component. See what events are being sent. Generate
274 irc commands manually. A TCP based console.
275
276 POE::Component::IRC::Plugin::Proxy
277 A lightweight IRC proxy/bouncer.
278
279 POE::Component::IRC::Plugin::CTCP
280 Automagically generates replies to ctcp version, time and userinfo
281 queries.
282
283 POE::Component::IRC::Plugin::PlugMan
284 An experimental Plugin Manager plugin.
285
286 POE::Component::IRC::Plugin::NickReclaim
287 Automagically deals with your nickname being in use and reclaiming
288 it.
289
291 Both CONSTRUCTORS return an object. The object is also available within
292 'irc_' event handlers by using $_[SENDER]->get_heap(). See also 'regis‐
293 ter' and 'irc_registered'.
294
295 spawn
296 Takes a number of arguments:
297
298 "alias", a name (kernel alias) that this instance will be known by;
299 "options", a hashref containing POE::Session options;
300
301 See 'connect()' for additional arguments that this method accepts.
302 All arguments are optional.
303
304 new This method is deprecated. See 'spawn' method instead. Takes one
305 argument: a name (kernel alias) which this new connection will be
306 known by. Returns a POE::Component::IRC object :) Use of this
307 method will generate a warning. There are currently no plans to
308 make it die() >;]
309
311 These are methods supported by the POE::Component::IRC object.
312
313 server_name
314 Takes no arguments. Returns the name of the IRC server that the
315 component is currently connected to.
316
317 nick_name
318 Takes no arguments. Returns a scalar containing the current nick‐
319 name that the bot is using.
320
321 session_id
322 Takes no arguments. Returns the ID of the component's session.
323 Ideal for posting events to the component.
324
325 $kernel->post( $irc->session_id() => 'mode' => $channel => '+o' =>
326 $dude );
327
328 session_alias
329 Takes no arguments. Returns the session alias that has been set
330 through spawn()'s alias argument.
331
332 version
333 Takes no arguments. Returns the version number of the module.
334
335 send_queue
336 The component provides anti-flood throttling. This method takes no
337 arguments and returns a scalar representing the number of messages
338 that are queued up waiting for dispatch to the irc server.
339
340 connected
341 Takes no arguments. Returns true or false depending on whether the
342 component is currently connected to an IRC network or not.
343
344 disconnect
345 Takes no arguments. Terminates the socket connection disgracefully
346 >;o]
347
348 raw_events
349 With no arguments, returns true or false depending on whether
350 'irc_raw' events are being generated or not. Provide a true or
351 false argument to enable or disable this feature accordingly.
352
353 isupport
354 Takes one argument, a server capability to query. Returns undef on
355 failure or a value representing the applicable capability. A full
356 list of capabilities is available at
357 <http://www.irc.org/tech_docs/005.html>.
358
359 isupport_dump_keys
360 Takes no arguments, returns a list of the available server capabil‐
361 ities keys, which can be used with isupport().
362
363 yield
364 This method provides an alternative object based means of posting
365 events to the component. First argument is the event to post, fol‐
366 lowing arguments are sent as arguments to the resultant post.
367
368 $irc->yield( 'mode' => $channel => '+o' => $dude );
369
370 call
371 This method provides an alternative object based means of calling
372 events to the component. First argument is the event to call, fol‐
373 lowing arguments are sent as arguments to the resultant call.
374
375 $irc->call( 'mode' => $channel => '+o' => $dude );
376
377 delay
378 This method provides a way of posting delayed events to the compo‐
379 nent. The first argument is an arrayref consisting of the delayed
380 command to post and any command arguments. The second argument is
381 the time in seconds that one wishes to delay the command being
382 posted.
383
384 my $alarm_id = $irc->delay( [ 'mode' => $channel => '+o' => $dude ], 60 );
385
386 Returns an alarm ID that can be used with delay_remove() to cancel
387 the delayed event. This will be undefined if something went wrong.
388
389 delay_remove
390 This method removes a previously scheduled delayed event from the
391 component. Takes one argument, the alarm_id that was returned by a
392 delay() method call.
393
394 my $arrayref = $irc->delay_remove( $alarm_id );
395
396 Returns an arrayref that was originally requested to be delayed.
397
398 resolver
399 Returns a reference to the POE::Component::Client::DNS object that
400 is internally created by the component.
401
402 pipeline
403 Returns a reference to the POE::Component::IRC::Pipeline object
404 used by the plugin system.
405
406 send_event
407 Sends an event through the components event handling system. These
408 will get processed by plugins then by registered sessions. First
409 argument is the event name, followed by any parameters for that
410 event.
411
413 How to talk to your new IRC component... here's the events we'll
414 accept. These are events that are posted to the component, either via
415 $poe_kernel->post() or via the object method yield().
416
417 So the following would be functionally equivalent:
418
419 sub irc_001 {
420 my ($kernel,$sender) = @_[KERNEL,SENDER];
421 my $irc = $sender->get_heap(); # obtain the poco's object
422
423 $irc->yield( privmsg => 'foo' => 'Howdy!' );
424 $kernel->post( $sender => privmsg => 'foo' => 'Howdy!' );
425 $kernel->post( $irc->session_id() => privmsg => 'foo' => 'Howdy!' );
426 $kernel->post( $irc->session_alias() => privmsg => 'foo' => 'Howdy!' );
427
428 undef;
429 }
430
431 Important Commands
432
433 register
434 Takes N arguments: a list of event names that your session wants to
435 listen for, minus the "irc_" prefix. So, for instance, if you just
436 want a bot that keeps track of which people are on a channel,
437 you'll need to listen for JOINs, PARTs, QUITs, and KICKs to people
438 on the channel you're in. You'd tell POE::Component::IRC that you
439 want those events by saying this:
440
441 $kernel->post( 'my client', 'register', qw(join part quit kick) );
442
443 Then, whenever people enter or leave a channel your bot is on
444 (forcibly or not), your session will receive events with names like
445 "irc_join", "irc_kick", etc., which you can use to update a list of
446 people on the channel.
447
448 Registering for 'all' will cause it to send all IRC-related events
449 to you; this is the easiest way to handle it. See the test script
450 for an example.
451
452 Registering will generate an 'irc_registered' event that your ses‐
453 sion can trap. ARG0 is the components object. Useful if you want to
454 bolt PoCo-IRC's new features such as Plugins into a bot coded to
455 the older deprecated API. If you are using the new API, ignore
456 this :)
457
458 Registering with multiple component sessions can be tricky, espe‐
459 cially if one wants to marry up sessions/objects, etc. Check 'SIG‐
460 NALS' section of this documentation for an alternative method of
461 registering with multiple poco-ircs.
462
463 Starting with version 4.96, if you spawn the component from inside
464 another POE session, the component will automatically register that
465 session as wanting 'all' irc events. That session will receive an
466 'irc_registered' event indicating that the component is up and
467 ready to go.
468
469 connect
470 Takes one argument: a hash reference of attributes for the new con‐
471 nection. This event tells the IRC client to connect to a new/dif‐
472 ferent server. If it has a connection already open, it'll close it
473 gracefully before reconnecting. Possible attributes for the new
474 connection are:
475
476 "Server", the server name;
477 "Port", the remote port number;
478 "Password", an optional password for restricted servers;
479 "Nick", your client's IRC nickname;
480 "Username", your client's username;
481 "Ircname", some cute comment or something.
482
483 "UseSSL", set to some true value if you want to connect using SSL.
484 "Raw", set to some true value to enable the component to send 'irc_raw' events.
485 "LocalAddr", which local IP address on a multihomed box to connect as;
486 "LocalPort", the local TCP port to open your socket on;
487 "NoDNS", set this to 1 to disable DNS lookups using PoCo-Client-DNS. ( See note below ).
488 "Flood", set this to 1 to get quickly disconnected and klined from an ircd >;]
489 "Proxy", IP address or server name of a proxy server to use.
490 "ProxyPort", which tcp port on the proxy to connect to.
491 "NATAddr", what other clients see as your IP address.
492 "DCCPorts", an arrayref containing tcp ports that can be used for DCC sends.
493 "Resolver", provide a POE::Component::Client::DNS object for the component to use.
494 "plugin_debug", set to some true value to print plugin debug info, default 0.
495 "socks_proxy", specify a SOCKS4/SOCKS4a proxy to use.
496 "socks_port", the SOCKS port to use, defaults to 1080 if not specified.
497 "socks_id", specify a SOCKS user_id. Default is none.
498 "useipv6", enable the use of IPv6 for connections.
499
500 "connect()" will supply reasonable defaults for any of these
501 attributes which are missing, so don't feel obliged to write them
502 all out.
503
504 If the component finds that POE::Component::Client::DNS is
505 installed it will use that to resolve the server name passed. Dis‐
506 able this behaviour if you like, by passing: NoDNS => 1.
507
508 Additionally there is a "Flood" parameter. When true, it disables
509 the component's flood protection algorithms, allowing it to send
510 messages to an IRC server at full speed. Disconnects and k-lines
511 are some common side effects of flooding IRC servers, so care
512 should be used when enabling this option.
513
514 Two new attributes are "Proxy" and "ProxyPort" for sending your IRC
515 traffic through a proxy server. "Proxy"'s value should be the IP
516 address or server name of the proxy. "ProxyPort"'s value should be
517 the port on the proxy to connect to. "connect()" will default to
518 using the actual IRC server's port if you provide a proxy but omit
519 the proxy's port. These are for HTTP Proxies. See 'socks_proxy' for
520 SOCKS4 and SOCKS4a support.
521
522 For those people who run bots behind firewalls and/or Network
523 Address Translation there are two additional attributes for DCC.
524 "DCCPorts", is an arrayref of ports to use when initiating DCC,
525 using dcc(). "NATAddr", is the NAT'ed IP address that your bot is
526 hidden behind, this is sent whenever you do DCC.
527
528 SSL support requires POE::Component::SSLify, as well as an IRC
529 server that supports SSL connections. If you're missing POE::Compo‐
530 nent::SSLify, specifing 'UseSSL' will do nothing. The default is to
531 not try to use SSL.
532
533 Setting 'Raw' to true, will enable the component to send 'irc_raw'
534 events to interested plugins and sessions. See below for more
535 details on what a 'irc_raw' events is :)
536
537 'NoDNS' has different results depending on whether it is set with
538 spawn() or connect(). Setting it with spawn(), disables the cre‐
539 ation of the POE::Component::Client::DNS completely. Setting it
540 with connect() on the other hand allows the PoCo-Client-DNS session
541 to be spawned, but will disable any dns lookups using it.
542
543 'Resolver', requires a POE::Component::Client::DNS object. Useful
544 when spawning multiple poco-irc sessions , saves the overhead of
545 multiple dns sessions.
546
547 'plugin_debug', setting to true enables plugin debug info. Plugins
548 are processed inside an eval, so debugging them can be hard. This
549 should help with that.
550
551 SOCKS4 proxy support is provided by 'socks_proxy', 'socks_port' and
552 'socks_id' parameters. If something goes wrong with the SOCKS con‐
553 nection you should get a warning on STDERR. This is fairly experi‐
554 mental currently.
555
556 IPv6 support is available for connecting to IPv6 enabled ircds ( it
557 won't work for DCC though ). To enable it, specify 'useipv6'.
558 Socket6 is required to be installed. If you have Socket6 and
559 POE::Component::Client::DNS installed and specify a hostname that
560 resolves to an IPv6 address then IPv6 will be used. If you specify
561 an ipv6 'localaddr' then IPv6 will be used.
562
563 ctcp and ctcpreply
564 Sends a CTCP query or response to the nick(s) or channel(s) which
565 you specify. Takes 2 arguments: the nick or channel to send a mes‐
566 sage to (use an array reference here to specify multiple recipi‐
567 ents), and the plain text of the message to send (the CTCP quoting
568 will be handled for you). The "/me" command in popular IRC clients
569 is actually a CTCP action.
570
571 # Doing a /me
572 $poe_kernel->post( $irc_session => ctcp => $channel => "ACTION dances." );
573
574 dcc Send a DCC SEND or CHAT request to another person. Takes at least
575 two arguments: the nickname of the person to send the request to
576 and the type of DCC request (SEND or CHAT). For SEND requests, be
577 sure to add a third argument for the filename you want to send.
578 Optionally, you can add a fourth argument for the DCC transfer
579 blocksize, but the default of 1024 should usually be fine.
580
581 Incidentally, you can send other weird nonstandard kinds of DCCs
582 too; just put something besides 'SEND' or 'CHAT' (say, "FOO") in
583 the type field, and you'll get back "irc_dcc_foo" events when
584 activity happens on its DCC connection.
585
586 If you are behind a firewall or Network Address Translation, you
587 may want to consult 'connect()' for some parameters that are useful
588 with this command.
589
590 dcc_accept
591 Accepts an incoming DCC connection from another host. First argu‐
592 ment: the magic cookie from an 'irc_dcc_request' event. In the case
593 of a DCC GET, the second argument can optionally specify a new name
594 for the destination file of the DCC transfer, instead of using the
595 sender's name for it. (See the 'irc_dcc_request' section below for
596 more details.)
597
598 dcc_chat
599 Sends lines of data to the person on the other side of a DCC CHAT
600 connection. Takes any number of arguments: the magic cookie from an
601 'irc_dcc_start' event, followed by the data you wish to send.
602 (It'll be chunked into lines by a POE::Filter::Line for you, don't
603 worry.)
604
605 dcc_close
606 Terminates a DCC SEND or GET connection prematurely, and causes DCC
607 CHAT connections to close gracefully. Takes one argument: the magic
608 cookie from an 'irc_dcc_start' or 'irc_dcc_request' event.
609
610 join
611 Tells your IRC client to join a single channel of your choice.
612 Takes at least one arg: the channel name (required) and the channel
613 key (optional, for password-protected channels).
614
615 kick
616 Tell the IRC server to forcibly evict a user from a particular
617 channel. Takes at least 2 arguments: a channel name, the nick of
618 the user to boot, and an optional witty message to show them as
619 they sail out the door.
620
621 remove ( Freenode only )
622 Tell the IRC server to forcibly evict a user from a particular
623 channel. Takes at least 2 arguments: a channel name, the nick of
624 the user to boot, and an optional witty message to show them as
625 they sail out the door. Similar to KICK but does an enforced PART
626 instead.
627
628 mode
629 Request a mode change on a particular channel or user. Takes at
630 least one argument: the mode changes to effect, as a single string
631 (e.g., "+sm-p+o"), and any number of optional operands to the mode
632 changes (nicks, hostmasks, channel keys, whatever.) Or just pass
633 them all as one big string and it'll still work, whatever. I regret
634 that I haven't the patience now to write a detailed explanation,
635 but serious IRC users know the details anyhow.
636
637 nick
638 Allows you to change your nickname. Takes exactly one argument: the
639 new username that you'd like to be known as.
640
641 notice
642 Sends a NOTICE message to the nick(s) or channel(s) which you spec‐
643 ify. Takes 2 arguments: the nick or channel to send a notice to
644 (use an array reference here to specify multiple recipients), and
645 the text of the notice to send.
646
647 part
648 Tell your IRC client to leave the channels which you pass to it.
649 Takes any number of arguments: channel names to depart from.
650
651 privmsg
652 Sends a public or private message to the nick(s) or channel(s)
653 which you specify. Takes 2 arguments: the nick or channel to send a
654 message to (use an array reference here to specify multiple recipi‐
655 ents), and the text of the message to send.
656
657 To send IRC colours wrap the text you want coloured with \x03 fol‐
658 lowed by the colour code, your text and a \x03 to switch back.
659
660 $kernel->post( $sender => privmsg => $channel => "Foo \x034bar\x03" );
661
662 The colour codes are:
663
664 1 - Black
665 2 - Navy Blue
666 3 - Green
667 4 - Red
668 5 - Brown
669 6 - Purple
670 7 - Olive
671 8 - Yellow
672 9 - Lime Green
673 10 - Teal
674 11 - Aqua Light
675 12 - Royal Blue
676 13 - Hot Pink
677 14 - Dark Gray
678 15 - Light Gray
679 16 - White
680
681 quit
682 Tells the IRC server to disconnect you. Takes one optional argu‐
683 ment: some clever, witty string that other users in your channels
684 will see as you leave. You can expect to get an "irc_disconnect"
685 event shortly after sending this.
686
687 shutdown
688 By default, POE::Component::IRC sessions never go away. Even after
689 they're disconnected, they're still sitting around in the back‐
690 ground, waiting for you to call "connect()" on them again to recon‐
691 nect. (Whether this behavior is the Right Thing is doubtful, but I
692 don't want to break backwards compatibility at this point.) You can
693 send the IRC session a "shutdown" event manually to make it delete
694 itself.
695
696 If you are connected, 'shutdown' will send a quit message to ircd
697 and disconnect. If you provide an argument that will be used as the
698 QUIT message.
699
700 Terminating multiple components can be tricky. Check the 'SIGNALS'
701 section of this documentation for an alternative method of shutting
702 down multiple poco-ircs.
703
704 unregister
705 Takes N arguments: a list of event names which you don't want to
706 receive. If you've previously done a 'register' for a particular
707 event which you no longer care about, this event will tell the IRC
708 connection to stop sending them to you. (If you haven't, it just
709 ignores you. No big deal.)
710
711 If you have registered with 'all', attempting to unregister indi‐
712 vidual events such as 'mode', etc. will not work. This is a 'fea‐
713 ture'.
714
715 debug
716 Takes 1 argument: 0 to turn debugging off or 1 to turn debugging
717 on. This turns debugging on in POE::Filter::IRC, POE::Fil‐
718 ter::CTCP, and POE::Component::IRC. This has the same effect as
719 setting Debug to true in 'connect'.
720
721 Not-So-Important Commands
722
723 admin
724 Asks your server who your friendly neighborhood server administra‐
725 tors are. If you prefer, you can pass it a server name to query,
726 instead of asking the server you're currently on.
727
728 away
729 When sent with an argument (a message describig where you went),
730 the server will note that you're now away from your machine or oth‐
731 erwise preoccupied, and pass your message along to anyone who tries
732 to communicate with you. When sent without arguments, it tells the
733 server that you're back and paying attention.
734
735 info
736 Basically the same as the "version" command, except that the server
737 is permitted to return any information about itself that it thinks
738 is relevant. There's some nice, specific standards-writing for ya,
739 eh?
740
741 invite
742 Invites another user onto an invite-only channel. Takes 2 argu‐
743 ments: the nick of the user you wish to admit, and the name of the
744 channel to invite them to.
745
746 ison
747 Asks the IRC server which users out of a list of nicknames are cur‐
748 rently online. Takes any number of arguments: a list of nicknames
749 to query the IRC server about.
750
751 links
752 Asks the server for a list of servers connected to the IRC network.
753 Takes two optional arguments, which I'm too lazy to document here,
754 so all you would-be linklooker writers should probably go dig up
755 the RFC.
756
757 list
758 Asks the server for a list of visible channels and their topics.
759 Takes any number of optional arguments: names of channels to get
760 topic information for. If called without any channel names, it'll
761 list every visible channel on the IRC network. This is usually a
762 really big list, so don't do this often.
763
764 motd
765 Request the server's "Message of the Day", a document which typi‐
766 cally contains stuff like the server's acceptable use policy and
767 admin contact email addresses, et cetera. Normally you'll automati‐
768 cally receive this when you log into a server, but if you want it
769 again, here's how to do it. If you'd like to get the MOTD for a
770 server other than the one you're logged into, pass it the server's
771 hostname as an argument; otherwise, no arguments.
772
773 names
774 Asks the server for a list of nicknames on particular channels.
775 Takes any number of arguments: names of channels to get lists of
776 users for. If called without any channel names, it'll tell you the
777 nicks of everyone on the IRC network. This is a really big list, so
778 don't do this much.
779
780 quote
781 Sends a raw line of text to the server. Takes one argument: a
782 string of a raw IRC command to send to the server. It is more opti‐
783 mal to use the events this module supplies instead of writing raw
784 IRC commands yourself.
785
786 stats
787 Returns some information about a server. Kinda complicated and not
788 terribly commonly used, so look it up in the RFC if you're curious.
789 Takes as many arguments as you please.
790
791 time
792 Asks the server what time it thinks it is, which it will return in
793 a human-readable form. Takes one optional argument: a server name
794 to query. If not supplied, defaults to current server.
795
796 topic
797 Retrieves or sets the topic for particular channel. If called with
798 just the channel name as an argument, it will ask the server to
799 return the current topic. If called with the channel name and a
800 string, it will set the channel topic to that string. Supply an
801 empty string to unset a channel topic.
802
803 trace
804 If you pass a server name or nick along with this request, it asks
805 the server for the list of servers in between you and the thing you
806 mentioned. If sent with no arguments, it will show you all the
807 servers which are connected to your current server.
808
809 userhost
810 Asks the IRC server for information about particular nicknames.
811 (The RFC doesn't define exactly what this is supposed to return.)
812 Takes any number of arguments: the nicknames to look up.
813
814 users
815 Asks the server how many users are logged into it. Defaults to the
816 server you're currently logged into; however, you can pass a server
817 name as the first argument to query some other machine instead.
818
819 version
820 Asks the server about the version of ircd that it's running. Takes
821 one optional argument: a server name to query. If not supplied,
822 defaults to current server.
823
824 who Lists the logged-on users matching a particular channel name, host‐
825 name, nickname, or what-have-you. Takes one optional argument: a
826 string for it to search for. Wildcards are allowed; in the absence
827 of this argument, it will return everyone who's currently logged in
828 (bad move). Tack an "o" on the end if you want to list only IRCops,
829 as per the RFC.
830
831 whois
832 Queries the IRC server for detailed information about a particular
833 user. Takes any number of arguments: nicknames or hostmasks to ask
834 for information about. As of version 3.2, you will receive an
835 'irc_whois' event in addition to the usual numeric responses. See
836 below for details.
837
838 whowas
839 Asks the server for information about nickname which is no longer
840 connected. Takes at least one argument: a nickname to look up (no
841 wildcards allowed), the optional maximum number of history entries
842 to return, and the optional server hostname to query. As of version
843 3.2, you will receive an 'irc_whowas' event in addition to the
844 usual numeric responses. See below for details.
845
846 ping/pong
847 Included for completeness sake. The component will deal with pong‐
848 ing to pings automatically. Don't worry about it.
849
850 Purely Esoteric Commands
851
852 locops
853 Opers-only command. This one sends a message to all currently
854 logged-on local-opers (+l). This option is specific to EFNet.
855
856 oper
857 In the exceedingly unlikely event that you happen to be an IRC
858 operator, you can use this command to authenticate with your IRC
859 server. Takes 2 arguments: your username and your password.
860
861 operwall
862 Opers-only command. This one sends a message to all currently
863 logged-on global opers. This option is specific to EFNet.
864
865 rehash
866 Tells the IRC server you're connected to, to rehash its configura‐
867 tion files. Only useful for IRCops. Takes no arguments.
868
869 die Tells the IRC server you're connect to, to terminate. Only useful
870 for IRCops, thank goodness. Takes no arguments.
871
872 restart
873 Tells the IRC server you're connected to, to shut down and restart
874 itself. Only useful for IRCops, thank goodness. Takes no argu‐
875 ments.
876
877 sconnect
878 Tells one IRC server (which you have operator status on) to connect
879 to another. This is actually the CONNECT command, but I already had
880 an event called 'connect', so too bad. Takes the args you'd expect:
881 a server to connect to, an optional port to connect on, and an
882 optional remote server to connect with, instead of the one you're
883 currently on.
884
885 summon
886 Don't even ask.
887
888 wallops
889 Another opers-only command. This one sends a message to all cur‐
890 rently logged-on opers (and +w users); sort of a mass PA system for
891 the IRC server administrators. Takes one argument: some clever,
892 witty message to send.
893
895 The events you will receive (or can ask to receive) from your running
896 IRC component. Note that all incoming event names your session will
897 receive are prefixed by "irc_", to inhibit event namespace pollution.
898
899 If you wish, you can ask the client to send you every event it gener‐
900 ates. Simply register for the event name "all". This is a lot easier
901 than writing a huge list of things you specifically want to listen for.
902 FIXME: I'd really like to classify these somewhat ("basic", "oper",
903 "ctcp", "dcc", "raw" or some such), and I'd welcome suggestions for
904 ways to make this easier on the user, if you can think of some.
905
906 In your event handlers, $_[SENDER] is the particular component session
907 that sent you the event. $_[SENDER]->get_heap() will retrieve the com‐
908 ponent's object. Useful if you want on-the-fly access to the object and
909 it's methods.
910
911 Important Events
912
913 irc_connected
914 The IRC component will send an "irc_connected" event as soon as it
915 establishes a connection to an IRC server, before attempting to log
916 in. ARG0 is the server name.
917
918 NOTE: When you get an "irc_connected" event, this doesn't mean you
919 can start sending commands to the server yet. Wait until you
920 receive an irc_001 event (the server welcome message) before actu‐
921 ally sending anything back to the server.
922
923 irc_ctcp
924 irc_ctcp events are generated upon receipt of CTCP messages, in
925 addition to the irc_ctcp_* events mentioned below. They are iden‐
926 tical in every way to these, with one difference: instead of the *
927 being in the method name, it is prepended to the argument list.
928 For example, if someone types "/ctcp Flibble foo bar", an irc_ctcp
929 event will be sent with "foo" as ARG0, and the rest as given below.
930
931 It is not recommended that you register for both irc_ctcp and
932 irc_ctcp_* events, since they will both be fired and presumably
933 cause duplication.
934
935 irc_ctcp_*
936 irc_ctcp_whatever events are generated upon receipt of CTCP mes‐
937 sages. For instance, receiving a CTCP PING request generates an
938 irc_ctcp_ping event, CTCP ACTION (produced by typing "/me" in most
939 IRC clients) generates an irc_ctcp_action event, blah blah, so on
940 and so forth. ARG0 is the nick!hostmask of the sender. ARG1 is the
941 channel/recipient name(s). ARG2 is the text of the CTCP message.
942
943 Note that DCCs are handled separately -- see the 'irc_dcc_request'
944 event, below.
945
946 irc_ctcpreply_*
947 irc_ctcpreply_whatever messages are just like irc_ctcp_whatever
948 messages, described above, except that they're generated when a
949 response to one of your CTCP queries comes back. They have the same
950 arguments and such as irc_ctcp_* events.
951
952 irc_disconnected
953 The counterpart to irc_connected, sent whenever a socket connection
954 to an IRC server closes down (whether intentionally or unintention‐
955 ally). ARG0 is the server name.
956
957 irc_error
958 You get this whenever the server sends you an ERROR message. Expect
959 this to usually be accompanied by the sudden dropping of your con‐
960 nection. ARG0 is the server's explanation of the error.
961
962 irc_join
963 Sent whenever someone joins a channel that you're on. ARG0 is the
964 person's nick!hostmask. ARG1 is the channel name.
965
966 irc_invite
967 Sent whenever someone offers you an invitation to another channel.
968 ARG0 is the person's nick!hostmask. ARG1 is the name of the channel
969 they want you to join.
970
971 irc_kick
972 Sent whenever someone gets booted off a channel that you're on.
973 ARG0 is the kicker's nick!hostmask. ARG1 is the channel name. ARG2
974 is the nick of the unfortunate kickee. ARG3 is the explanation
975 string for the kick.
976
977 irc_mode
978 Sent whenever someone changes a channel mode in your presence, or
979 when you change your own user mode. ARG0 is the nick!hostmask of
980 that someone. ARG1 is the channel it affects (or your nick, if it's
981 a user mode change). ARG2 is the mode string (i.e., "+o-b"). The
982 rest of the args (ARG3 .. $#_) are the operands to the mode string
983 (nicks, hostmasks, channel keys, whatever).
984
985 irc_msg
986 Sent whenever you receive a PRIVMSG command that was addressed to
987 you privately. ARG0 is the nick!hostmask of the sender. ARG1 is an
988 array reference containing the nick(s) of the recipients. ARG2 is
989 the text of the message.
990
991 irc_nick
992 Sent whenever you, or someone around you, changes nicks. ARG0 is
993 the nick!hostmask of the changer. ARG1 is the new nick that they
994 changed to.
995
996 irc_notice
997 Sent whenever you receive a NOTICE command. ARG0 is the nick!host‐
998 mask of the sender. ARG1 is an array reference containing the
999 nick(s) or channel name(s) of the recipients. ARG2 is the text of
1000 the NOTICE message.
1001
1002 irc_part
1003 Sent whenever someone leaves a channel that you're on. ARG0 is the
1004 person's nick!hostmask. ARG1 is the channel name. ARG2 is the part
1005 message.
1006
1007 irc_ping
1008 An event sent whenever the server sends a PING query to the client.
1009 (Don't confuse this with a CTCP PING, which is another beast
1010 entirely. If unclear, read the RFC.) Note that POE::Component::IRC
1011 will automatically take care of sending the PONG response back to
1012 the server for you, although you can still register to catch the
1013 event for informational purposes.
1014
1015 irc_public
1016 Sent whenever you receive a PRIVMSG command that was sent to a
1017 channel. ARG0 is the nick!hostmask of the sender. ARG1 is an array
1018 reference containing the channel name(s) of the recipients. ARG2 is
1019 the text of the message.
1020
1021 irc_quit
1022 Sent whenever someone on a channel with you quits IRC (or gets
1023 KILLed). ARG0 is the nick!hostmask of the person in question. ARG1
1024 is the clever, witty message they left behind on the way out.
1025
1026 irc_socketerr
1027 Sent when a connection couldn't be established to the IRC server.
1028 ARG0 is probably some vague and/or misleading reason for what
1029 failed.
1030
1031 irc_topic
1032 Sent when a channel topic is set or unset. ARG0 is the nick!host‐
1033 mask of the sender. ARG1 is the channel affected. ARG2 will be
1034 either: a string if the topic is being set; or a zero-length string
1035 (ie. '') if the topic is being unset. Note: replies to queries
1036 about what a channel topic *is* (ie. TOPIC #channel) , are returned
1037 as numerics, not with this event.
1038
1039 irc_whois
1040 Sent in response to a 'whois' query. ARG0 is a hashref, with the
1041 following keys:
1042
1043 'nick', the users nickname;
1044 'user', the users username;
1045 'host', their hostname;
1046 'real', their real name;
1047 'idle', their idle time in seconds;
1048 'signon', the epoch time they signed on ( will be undef if ircd does not support this );
1049 'channels', an arrayref listing visible channels they are on, the channel is prefixed
1050 with '@','+','%' depending on whether they have +o +v or +h;
1051 'server', their server ( might not be useful on some networks );
1052 'oper', whether they are an IRCop, contains the IRC operator string if they are,
1053 undef if they aren't.
1054 'actually', some ircds report the users actual ip address, that'll be here;
1055
1056 On Freenode if the user has identified with NICKSERV there will be
1057 an additional key:
1058
1059 'identified'.
1060
1061 irc_whowas
1062 Similar to the above, except some keys will be missing.
1063
1064 irc_raw
1065 Enabled by passing 'Raw' => 1 to spawn() or connect(), ARG0 is the
1066 raw IRC string received by the component from the IRC server,
1067 before it has been mangled by filters and such like.
1068
1069 irc_registered
1070 Sent once to the requesting session on registration ( see regis‐
1071 ter() ). ARG0 is a reference to the component's object.
1072
1073 irc_shutdown
1074 Sent to all registered sessions when the component has been asked
1075 to shutdown(). ARG0 will be the session ID of the requesting ses‐
1076 sion.
1077
1078 irc_isupport
1079 Emitted by the first event after an irc_005, to indicate that isup‐
1080 port information has been gathered. ARG0 is the POE::Compo‐
1081 nent::IRC::Plugin::ISupport object.
1082
1083 irc_delay_set
1084 Emitted on a succesful addition of a delayed event using delay()
1085 method. ARG0 will be the alarm_id which can be used later with
1086 delay_remove(). Subsequent parameters are the arguments that were
1087 passed to delay().
1088
1089 irc_delay_removed
1090 Emitted when a delayed command is successfully removed. ARG0 will
1091 be the alarm_id that was removed. Subsequent parameters are the
1092 arguments that were passed to delay().
1093
1094 irc_socks_failed
1095 Emitted whenever we fail to connect successfully to a SOCKS server
1096 or the SOCKS server is not actually a SOCKS server. ARG0 will be
1097 some vague reason as to what went wrong. Hopefully.
1098
1099 irc_socks_rejected
1100 Emitted whenever a SOCKS connection is rejected by a SOCKS server.
1101 ARG0 is the SOCKS code, ARG1 the SOCKS server address, ARG2 the
1102 SOCKS port and ARG3 the SOCKS user id ( if defined ).
1103
1104 All numeric events (see RFC 1459)
1105 Most messages from IRC servers are identified only by three-digit
1106 numeric codes with undescriptive constant names like RPL_UMODEIS
1107 and ERR_NOTOPLEVEL. (Actually, the list of codes in the RFC is kind
1108 of out-of-date... the list in the back of Net::IRC::Event.pm is
1109 more complete, and different IRC networks have different and incom‐
1110 patible lists. Ack!) As an example, say you wanted to handle event
1111 376 (RPL_ENDOFMOTD, which signals the end of the MOTD message).
1112 You'd register for '376', and listen for 'irc_376' events. Simple,
1113 no? ARG0 is the name of the server which sent the message. ARG1 is
1114 the text of the message. ARG2 is an ARRAYREF of the parsed message,
1115 so there is no need to parse ARG1 yourself.
1116
1117 Somewhat Less Important Events
1118
1119 irc_dcc_chat
1120 Notifies you that one line of text has been received from the
1121 client on the other end of a DCC CHAT connection. ARG0 is the con‐
1122 nection's magic cookie, ARG1 is the nick of the person on the other
1123 end, ARG2 is the port number, and ARG3 is the text they sent.
1124
1125 irc_dcc_done
1126 You receive this event when a DCC connection terminates normally.
1127 Abnormal terminations are reported by "irc_dcc_error", below. ARG0
1128 is the connection's magic cookie, ARG1 is the nick of the person on
1129 the other end, ARG2 is the DCC type (CHAT, SEND, GET, etc.), and
1130 ARG3 is the port number. For DCC SEND and GET connections, ARG4
1131 will be the filename, ARG5 will be the file size, and ARG6 will be
1132 the number of bytes transferred. (ARG5 and ARG6 should always be
1133 the same.)
1134
1135 irc_dcc_failed
1136 You get this event when a DCC connection fails for some reason.
1137 ARG0 will be the operation that failed, ARG1 is the error number,
1138 ARG2 is the description of the error and ARG3 the connection's
1139 magic cookie.
1140
1141 irc_dcc_error
1142 You get this event whenever a DCC connection or connection attempt
1143 terminates unexpectedly or suffers some fatal error. ARG0 will be
1144 the connection's magic cookie, ARG1 will be a string describing the
1145 error. ARG2 will be the nick of the person on the other end of the
1146 connection. ARG3 is the DCC type (SEND, GET, CHAT, etc.). ARG4 is
1147 the port number of the DCC connection, if any. For SEND and GET
1148 connections, ARG5 is the filename, ARG6 is the expected file size,
1149 and ARG7 is the transfered size.
1150
1151 irc_dcc_get
1152 Notifies you that another block of data has been successfully
1153 transferred from the client on the other end of your DCC GET con‐
1154 nection. ARG0 is the connection's magic cookie, ARG1 is the nick
1155 of the person on the other end, ARG2 is the port number, ARG3 is
1156 the filename, ARG4 is the total file size, and ARG5 is the number
1157 of bytes successfully transferred so far.
1158
1159 irc_dcc_request
1160 You receive this event when another IRC client sends you a DCC SEND
1161 or CHAT request out of the blue. You can examine the request and
1162 decide whether or not to accept it here. ARG0 is the nick of the
1163 client on the other end. ARG1 is the type of DCC request (CHAT,
1164 SEND, etc.). ARG2 is the port number. ARG3 is a "magic cookie"
1165 argument, suitable for sending with 'dcc_accept' events to signify
1166 that you want to accept the connection (see the 'dcc_accept' docs).
1167 For DCC SEND and GET connections, ARG4 will be the filename, and
1168 ARG5 will be the file size.
1169
1170 irc_dcc_send
1171 Notifies you that another block of data has been successfully
1172 transferred from you to the client on the other end of a DCC SEND
1173 connection. ARG0 is the connection's magic cookie, ARG1 is the nick
1174 of the person on the other end, ARG2 is the port number, ARG3 is
1175 the filename, ARG4 is the total file size, and ARG5 is the number
1176 of bytes successfully transferred so far.
1177
1178 irc_dcc_start
1179 This event notifies you that a DCC connection has been successfully
1180 established. ARG0 is a unique "magic cookie" argument which you can
1181 pass to 'dcc_chat' or 'dcc_close'. ARG1 is the nick of the person
1182 on the other end, ARG2 is the DCC type (CHAT, SEND, GET, etc.), and
1183 ARG3 is the port number. For DCC SEND and GET connections, ARG4
1184 will be the filename and ARG5 will be the file size.
1185
1186 irc_snotice
1187 A weird, non-RFC-compliant message from an IRC server. Don't worry
1188 about it. ARG0 is the text of the server's message.
1189
1190 dcc_resume
1191 bboetts puny try to get dcc resume implemented in this great
1192 module:
1193 ARG0 is the well known 'magic cookie' (as in dcc_send etc.)
1194 ARG1 is the (eventually new) name of the file
1195 ARG2 is the size from which will be resumed
1196
1197 usage and example:
1198
1199 sub irc_dcc_request {
1200 my ($kernel, $nick, $type, $port, $magic, $filename, $size) =
1201 @_[KERNEL, ARG0 .. ARG5];
1202
1203 print "DCC $type request from $nick on port $port\n";
1204 if($args->{type} =~ /SEND/i)
1205 {
1206 $nick = ($nick =~ /^([^!]+)/);
1207 $nick =~ s/\W//;
1208 if(my $filesize = -s "$1.$filename")
1209 {
1210 $kernel->post('test', 'dcc_resume', $magic, "$1.$filename", "$filesize" );
1211 #dont forget to save the cookie, it holds the address of the counterpart which won't be in the server response!!
1212 $args->{heap}->{cookies}->{$args->{file}} = $args->{magic};
1213 }#if(-s "$1.$filename")
1214 else
1215 {
1216 $kernel->post( 'test', 'dcc_accept', $magic, "$1.$filename" );
1217 }#else
1218 }
1219 elsif($args->{type} =~ /ACCEPT/i)
1220 {
1221 $kernel->post( $args->{context}, 'dcc_accept', $magic, $filename);
1222 }
1223 }
1224 you need a counter part in irc_dcc_request:
1225
1226 if($type eq 'ACCEPT')
1227 {
1228 #the args are in wrong order and missing shift the args 1 up
1229 $magic->{port} = $magic->{addr};
1230
1231 my $altcookie = $_[OBJECT]->{cookies}->{$filename};
1232 $magic->{addr} = $altcookie->{addr};
1233 delete $_[OBJECT]->{cookies}->{$filename};
1234 #TODO beware a possible memory leak here...
1235 }# if($type eq 'ACCEPT')
1236
1238 The component will handle a number of custom signals that you may send
1239 using POE::Kernel signal() method.
1240
1241 POCOIRC_REGISTER
1242 Registering with multiple PoCo-IRC components has been a pita.
1243 Well, no more, using the power of POE::Kernel signals.
1244
1245 If the component receives a 'POCOIRC_REGISTER' signal it'll regis‐
1246 ter the requesting session and trigger an 'irc_registered' event.
1247 From that event one can get all the information necessary such as
1248 the poco-irc object and the SENDER session to do whatever one needs
1249 to build a poco-irc dispatch table.
1250
1251 The way the signal handler in PoCo-IRC is written also supports
1252 sending the 'POCOIRC_REGISTER' to multiple sessions simultaneously,
1253 by sending the signal to the POE Kernel itself.
1254
1255 Pass the signal your session, session ID or alias, and the IRC
1256 events ( as specified to 'register' ).
1257
1258 To register with multiple PoCo-IRCs one can do the following in
1259 your session's _start handler:
1260
1261 sub _start {
1262 my ($kernel,$session) = @_[KERNEL,SESSION];
1263
1264 # Registering with multiple pocoircs for 'all' IRC events
1265 $kernel->signal( $kernel, 'POCOIRC_REGISTER', $session->ID(), 'all' );
1266
1267 undef;
1268 }
1269
1270 Each poco-irc will send your session an 'irc_registered' event:
1271
1272 sub irc_registered {
1273 my ($kernel,$sender,$heap,$irc_object) = @_[KERNEL,SENDER,HEAP,ARG0];
1274
1275 # Get the poco-irc session ID
1276 my $sender_id = $sender->ID();
1277
1278 # Or it's alias
1279 my $poco_alias = $irc_object->session_alias();
1280
1281 # Store it in our heap maybe
1282 $heap->{irc_objects}->{ $sender_id } = $irc_object;
1283
1284 # Make the poco connect
1285 $irc_object->yield( connect => { } );
1286
1287 undef;
1288 }
1289
1290 POCOIRC_SHUTDOWN
1291 Telling multiple poco-ircs to shutdown was a pita as well. The same
1292 principle as with registering applies to shutdown too.
1293
1294 Send a 'POCOIRC_SHUTDOWN' to the POE Kernel to terminate all the
1295 active poco-ircs simultaneously.
1296
1297 $poe_kernel->signal( $poe_kernel, 'POCOIRC_SHUTDOWN' );
1298
1299 Any additional parameters passed to the signal will become your
1300 quit messages on each IRC network.
1301
1303 A few have turned up in the past and they are sure to again. Please use
1304 <http://rt.cpan.org/> to report any. Alternatively, email the current
1305 maintainer.
1306
1308 Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
1309
1311 Dennis Taylor.
1312
1314 Copyright (c) Dennis Taylor and Chris Williams
1315
1316 This module may be used, modified, and distributed under the same terms
1317 as Perl itself. Please see the license that came with your Perl distri‐
1318 bution for details.
1319
1321 The maddest of mad props go out to Rocco "dngor" Caputo
1322 <troc@netrus.net>, for inventing something as mind-bogglingly cool as
1323 POE, and to Kevin "oznoid" Lenzo <lenzo@cs.cmu.edu>, for being the
1324 attentive parent of our precocious little infobot on #perl.
1325
1326 Further props to a few of the studly bughunters who made this module
1327 not suck: Abys <abys@web1-2-3.com>, Addi <addi@umich.edu>, ResDev
1328 <ben@reser.org>, and Roderick <roderick@argon.org>. Woohoo!
1329
1330 Kudos to Apocalypse, <apocal@cpan.org>, for the plugin system and to
1331 Jeff 'japhy' Pinyan, <japhy@perlmonk.org>, for Pipeline.
1332
1333 Thanks to the merry band of POE pixies from #PoE @ irc.perl.org,
1334 including ( but not limited to ), ketas, ct, dec, integral, webfox,
1335 immute, perigrin, paulv, alias.
1336
1337 Check out the Changes file for further contributors.
1338
1340 RFC 1459 <http://www.faqs.org/rfcs/rfc1459.html>
1341
1342 <http://www.irchelp.org/>,
1343
1344 <http://poe.perl.org/>,
1345
1346 <http://www.infobot.org/>,
1347
1348 Some good examples reside in the POE cookbook which has a whole section
1349 devoted to IRC programming <http://poe.perl.org/?POE_Cookbook>.
1350
1351 The examples/ folder of this distribution.
1352
1353
1354
1355perl v5.8.8 2005-10-25 POE::Component::IRC(3)