1POE::Component::IRC::QnUeste(r3)Contributed Perl DocumenPtOaEt:i:oCnomponent::IRC::Qnet(3)
2
3
4

NAME

6       POE::Component::IRC::Qnet - A fully event-driven IRC client module for
7       Quakenet
8

SYNOPSIS

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        my @channels = ( '#Blah', '#Foo', '#Bar' );
20
21        # We create a new PoCo-IRC object and component.
22        my $irc = POE::Component::IRC::Qnet->spawn(
23            nick => $nickname,
24            port => $port,
25            ircname => $ircname,
26        ) or die "Oh noooo! $!";
27
28        POE::Session->create(
29            package_states => [
30                main => [ qw(_default _start irc_001 irc_public) ],
31            ],
32            heap => { irc => $irc },
33        );
34
35        $poe_kernel->run();
36
37        sub _start {
38            my ($kernel, $heap) = @_[KERNEL, HEAP];
39
40            # We get the session ID of the component from the object
41            # and register and connect to the specified server.
42            my $irc_session = $heap->{irc}->session_id();
43            $kernel->post( $irc_session => register => 'all' );
44            $kernel->post( $irc_session => connect => { } );
45            return;
46        }
47
48        sub irc_001 {
49            my ($kernel, $sender) = @_[KERNEL, SENDER];
50
51            # Get the component's object at any time by accessing the heap of
52            # the SENDER
53            my $poco_object = $sender->get_heap();
54            print "Connected to ", $poco_object->server_name(), "\n";
55
56            # Lets authenticate with Quakenet's Q bot
57            $kernel->post( $sender => qbot_auth => $qauth => $qpass );
58
59            return;
60        }
61
62        sub irc_public {
63            my ($kernel, $sender, $who, $where, $what) = @_[KERNEL, SENDER, ARG0 .. ARG2];
64            my $nick = ( split /!/, $who )[0];
65            my $channel = $where->[0];
66
67            if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) {
68                $rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M];
69                $kernel->post( $sender => privmsg => $channel => "$nick: $rot13" );
70            }
71            return;
72        }
73
74        # We registered for all events, this will produce some debug info.
75        sub _default {
76            my ($event, $args) = @_[ARG0 .. $#_];
77            my @output = ( "$event: " );
78
79            for my $arg ( @$args ) {
80                if (ref $arg eq 'ARRAY') {
81                    push( @output, '[' . join(', ', @$arg ) . ']' );
82                }
83                else {
84                    push ( @output, "'$arg'" );
85                }
86            }
87            print join ' ', @output, "\n";
88            return 0;
89        }
90

DESCRIPTION

92       POE::Component::IRC::Qnet is an extension to POE::Component::IRC
93       specifically for use on Quakenet <http://www.quakenet.org/>. See the
94       documentation for POE::Component::IRC for general usage.  This document
95       covers the extensions.
96
97       The module provides a number of additional commands for communicating
98       with the Quakenet service bot Q.
99

METHODS

101   "service_bots"
102       The component will query Q its default name on Quakenet. If you wish to
103       override these settings, use this method to configure them.
104
105        $irc->service_bots(QBOT => 'W@blah.network.net');
106
107       In most cases you shouldn't need to mess with these >;o)
108

INPUT

110       The Quakenet service bots accept input as PRIVMSG. This module provides
111       a wrapper around the POE::Component::IRC "privmsg" command.
112
113   "qbot_*"
114       Send commands to the Q bot. Pass additional command parameters as
115       arguments to the event.
116
117        $kernel->post ('my client' => qbot_auth => $q_user => $q_pass);
118

OUTPUT EVENTS

120       All output from the Quakenet service bots is sent as NOTICEs.  Use
121       "irc_notice" to trap these.
122
123   "irc_whois"
124       Has all the same hash keys in "ARG1" as POE::Component::IRC, with the
125       addition of 'account', which contains the name of their Q auth account,
126       if they have authed, or a false value if they haven't.
127

BUGS

129       A few have turned up in the past and they are sure to again. Please use
130       <http://rt.cpan.org/> to report any. Alternatively, email the current
131       maintainer.
132

AUTHOR

134       Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
135
136       Based on the original POE::Component::IRC by:
137
138       Dennis Taylor, <dennis@funkplanet.com>
139

SEE ALSO

141       POE::Component::IRC
142
143       <http://www.quakenet.org/>
144
145
146
147perl v5.38.0                      2023-07-21      POE::Component::IRC::Qnet(3)
Impressum