1POE::Component::IRC::QnUeste(r3)Contributed Perl DocumenPtOaEt:i:oCnomponent::IRC::Qnet(3)
2
3
4
6 POE::Component::IRC::Qnet - a fully event-driven IRC client module for
7 Quakenet.
8
10 use strict;
11 use warnings;
12 use POE qw(Component::IRC::Qnet);
13
14 my $nickname = 'Flibble' . $$;
15 my $ircname = 'Flibble the Sailor Bot';
16 my $port = 6667;
17 my $qauth = 'FlibbleBOT';
18 my $qpass = 'fubar';
19
20 my @channels = ( '#Blah', '#Foo', '#Bar' );
21
22 # We create a new PoCo-IRC object and component.
23 my $irc = POE::Component::IRC::Qnet->spawn(
24 nick => $nickname,
25 port => $port,
26 ircname => $ircname,
27 ) or die "Oh noooo! $!";
28
29 POE::Session->create(
30 package_states => [
31 'main' => [ qw(_default _start irc_001 irc_public) ],
32 ],
33 heap => { irc => $irc },
34 );
35
36 $poe_kernel->run();
37 exit 0;
38
39 sub _start {
40 my ($kernel,$heap) = @_[KERNEL,HEAP];
41
42 # We get the session ID of the component from the object
43 # and register and connect to the specified server.
44 my $irc_session = $heap->{irc}->session_id();
45 $kernel->post( $irc_session => register => 'all' );
46 $kernel->post( $irc_session => connect => { } );
47 undef;
48 }
49
50 sub irc_001 {
51 my ($kernel,$sender) = @_[KERNEL,SENDER];
52
53 # Get the component's object at any time by accessing the heap of
54 # the SENDER
55 my $poco_object = $sender->get_heap();
56 print "Connected to ", $poco_object->server_name(), "\n";
57
58 # Lets authenticate with Quakenet's Q bot
59 $kernel->post( $sender => qbot_auth => $qauth => $qpass );
60
61 # In any irc_* events SENDER will be the PoCo-IRC session
62 $kernel->post( $sender => join => $_ ) for @channels;
63 undef;
64 }
65
66 sub irc_public {
67 my ($kernel,$sender,$who,$where,$what) = @_[KERNEL,SENDER,ARG0,ARG1,ARG2];
68 my $nick = ( split /!/, $who )[0];
69 my $channel = $where->[0];
70
71 if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) {
72 $rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M];
73 $kernel->post( $sender => privmsg => $channel => "$nick: $rot13" );
74 }
75 undef;
76 }
77
78 # We registered for all events, this will produce some debug info.
79 sub _default {
80 my ($event, $args) = @_[ARG0 .. $#_];
81 my @output = ( "$event: " );
82
83 foreach my $arg ( @$args ) {
84 if ( ref($arg) eq 'ARRAY' ) {
85 push( @output, "[" . join(" ,", @$arg ) . "]" );
86 } else {
87 push ( @output, "'$arg'" );
88 }
89 }
90 print STDOUT join ' ', @output, "\n";
91 return 0;
92 }
93
95 POE::Component::IRC::Qnet is an extension to POE::Component::IRC
96 specifically for use on Quakenet <http://www.quakenet.org/>. See the
97 documentation for POE::Component::IRC for general usage. This document
98 covers the extensions.
99
100 The module provides a number of additional commands for communicating
101 with the Quakenet service bots, Q and L.
102
104 service_bots
105 The component will query Q and L using their default names on Quak‐
106 enet. If you wish to override these settings, use this method to
107 configure them.
108
109 $self->service_bots( QBOT => 'W@blah.network.net', LBOT =>
110 'Z@blah.network.net' );
111
112 In most cases you shouldn't need to mess with these >;o)
113
115 The Quakenet service bots accept input as PRIVMSG. This module provides
116 a wrapper around the POE::Component::IRC "privmsg" command.
117
118 qbot_*
119 Send commands to the Q bot. Pass additional command parameters as
120 arguments to the event.
121
122 $kernel->post ( 'my client' => qbot_auth => $q_user => $q_pass );
123
124 lbot_*
125 Send commands to the L bot. Pass additional command parameters as
126 arguments to the event.
127
128 $kernel->post ( 'my client' => lbot_chanlev => $channel );
129
131 All output from the Quakenet service bots is sent as NOTICEs. Use
132 'irc_notice' to trap these.
133
134 irc_whois
135 Has all the same hash keys in ARG1 as POE::Component::IRC, with the
136 addition of 'account', which contains the name of their Q auth
137 account, if they have authed, or undef if they haven't.
138
140 A few have turned up in the past and they are sure to again. Please use
141 <http://rt.cpan.org/> to report any. Alternatively, email the current
142 maintainer.
143
145 Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
146
147 Based on the original POE::Component::IRC by:
148
149 Dennis Taylor, <dennis@funkplanet.com>
150
152 POE::Component::IRC
153
154 <http://www.quakenet.org/>
155
156
157
158perl v5.8.8 2005-10-25 POE::Component::IRC::Qnet(3)