/usr/share/perl5/POE/Component/IRC/Qnet.pm is in libpoe-component-irc-perl 6.88+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | package POE::Component::IRC::Qnet;
BEGIN {
$POE::Component::IRC::Qnet::AUTHORITY = 'cpan:HINRIK';
}
$POE::Component::IRC::Qnet::VERSION = '6.88';
use strict;
use warnings FATAL => 'all';
use Carp;
use POE;
use POE::Component::IRC::Constants qw(:ALL);
use base qw(POE::Component::IRC);
sub _create {
my $self = shift;
$self->SUPER::_create();
# Stuff specific to IRC-Qnet
my @qbot_commands = qw(
hello
whoami
challengeauth
showcommands
auth
challenge
help
unlock
requestpassword
reset
newpass
email
authhistory
banclear
op
invite
removeuser
banlist
recover
limit
unbanall
whois
version
autolimit
ban
clearchan
adduser
settopic
chanflags
deopall
requestowner
bandel
chanlev
key
welcome
voice
);
$self->{OBJECT_STATES_HASHREF}->{'qbot_' . $_} = '_qnet_bot_commands' for @qbot_commands;
$self->{server} = 'irc.quakenet.org';
$self->{QBOT} = 'Q@Cserve.quakenet.org';
return 1;
}
sub _qnet_bot_commands {
my ($kernel, $state, $self) = @_[KERNEL,STATE,OBJECT];
my $message = join ' ', @_[ARG0 .. $#_];
my $pri = $self->{IRC_CMDS}->{'privmsghi'}->[CMD_PRI];
my $command = "PRIVMSG ";
my ($target,$cmd) = split(/_/,$state);
$command .= join(' :',$self->{uc $target},uc($cmd));
$command = join(' ',$command,$message) if defined ( $message );
$kernel->yield( 'sl_prioritized', $pri, $command );
return;
}
sub service_bots {
my ($self, %args) = @_;
for my $botname ( qw(QBOT) ) {
if ( defined ( $args{$botname} ) ) {
$self->{$botname} = $args{$botname};
}
}
return 1;
}
1;
=encoding utf8
=head1 NAME
POE::Component::IRC::Qnet - A fully event-driven IRC client module for Quakenet
=head1 SYNOPSIS
use strict;
use warnings;
use POE qw(Component::IRC::Qnet);
my $nickname = 'Flibble' . $$;
my $ircname = 'Flibble the Sailor Bot';
my $port = 6667;
my $qauth = 'FlibbleBOT';
my $qpass = 'fubar';
my @channels = ( '#Blah', '#Foo', '#Bar' );
# We create a new PoCo-IRC object and component.
my $irc = POE::Component::IRC::Qnet->spawn(
nick => $nickname,
port => $port,
ircname => $ircname,
) or die "Oh noooo! $!";
POE::Session->create(
package_states => [
main => [ qw(_default _start irc_001 irc_public) ],
],
heap => { irc => $irc },
);
$poe_kernel->run();
sub _start {
my ($kernel, $heap) = @_[KERNEL, HEAP];
# We get the session ID of the component from the object
# and register and connect to the specified server.
my $irc_session = $heap->{irc}->session_id();
$kernel->post( $irc_session => register => 'all' );
$kernel->post( $irc_session => connect => { } );
return;
}
sub irc_001 {
my ($kernel, $sender) = @_[KERNEL, SENDER];
# Get the component's object at any time by accessing the heap of
# the SENDER
my $poco_object = $sender->get_heap();
print "Connected to ", $poco_object->server_name(), "\n";
# Lets authenticate with Quakenet's Q bot
$kernel->post( $sender => qbot_auth => $qauth => $qpass );
return;
}
sub irc_public {
my ($kernel, $sender, $who, $where, $what) = @_[KERNEL, SENDER, ARG0 .. ARG2];
my $nick = ( split /!/, $who )[0];
my $channel = $where->[0];
if ( my ($rot13) = $what =~ /^rot13 (.+)/ ) {
$rot13 =~ tr[a-zA-Z][n-za-mN-ZA-M];
$kernel->post( $sender => privmsg => $channel => "$nick: $rot13" );
}
return;
}
# We registered for all events, this will produce some debug info.
sub _default {
my ($event, $args) = @_[ARG0 .. $#_];
my @output = ( "$event: " );
for my $arg ( @$args ) {
if (ref $arg eq 'ARRAY') {
push( @output, '[' . join(', ', @$arg ) . ']' );
}
else {
push ( @output, "'$arg'" );
}
}
print join ' ', @output, "\n";
return 0;
}
=head1 DESCRIPTION
POE::Component::IRC::Qnet is an extension to L<POE::Component::IRC|POE::Component::IRC>
specifically for use on Quakenet L<http://www.quakenet.org/>. See the
documentation for L<POE::Component::IRC|POE::Component::IRC> for general usage.
This document covers the extensions.
The module provides a number of additional commands for communicating with the
Quakenet service bot Q.
=head1 METHODS
=head2 C<service_bots>
The component will query Q its default name on Quakenet. If you
wish to override these settings, use this method to configure them.
$irc->service_bots(QBOT => 'W@blah.network.net');
In most cases you shouldn't need to mess with these >;o)
=head1 INPUT
The Quakenet service bots accept input as PRIVMSG. This module provides a
wrapper around the L<POE::Component::IRC> "privmsg" command.
=head2 C<qbot_*>
Send commands to the Q bot. Pass additional command parameters as arguments to
the event.
$kernel->post ('my client' => qbot_auth => $q_user => $q_pass);
=head1 OUTPUT EVENTS
All output from the Quakenet service bots is sent as NOTICEs.
Use L<C<irc_notice>|POE::Component::IRC/irc_notice> to trap these.
=head2 C<irc_whois>
Has all the same hash keys in C<ARG1> as L<POE::Component::IRC|POE::Component::IRC>,
with the addition of B<'account'>, which contains the name of their Q auth account,
if they have authed, or a false value if they haven't.
=head1 BUGS
A few have turned up in the past and they are sure to again. Please use
L<http://rt.cpan.org/> to report any. Alternatively, email the current maintainer.
=head1 AUTHOR
Chris 'BinGOs' Williams E<lt>chris@bingosnet.co.ukE<gt>
Based on the original POE::Component::IRC by:
Dennis Taylor, <dennis@funkplanet.com>
=head1 SEE ALSO
L<POE::Component::IRC>
L<http://www.quakenet.org/>
=cut
|