-
Notifications
You must be signed in to change notification settings - Fork 3
/
Qauth.pm
66 lines (51 loc) · 1.26 KB
/
Qauth.pm
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
package Qauth;
use POE::Component::IRC::Plugin qw( :ALL );
our ($QBOT) = '[email protected]';
our ($LBOT) = '[email protected]';
our ($QFULL) = '[email protected]';
our ($LFULL) = '[email protected]';
sub new {
my ($package) = shift;
return bless { @_ }, $package;
}
sub PCI_register {
my ($self,$irc) = splice @_, 0, 2;
$self->{irc} = $irc;
$irc->plugin_register( $self, 'SERVER', qw(all) );
return 1;
}
sub PCI_unregister {
my ($self,$irc) = splice @_, 0, 2;
delete ( $self->{irc} );
return 1;
}
sub S_001 {
my ($self,$irc) = splice @_, 0, 2;
if ( $irc->server_name() =~ /quakenet\.org$/i ) {
if ( $self->{qauth} and $self->{qpass} ) {
$irc->yield( privmsg => $QBOT => 'AUTH' => $self->{qauth} => $self->{qpass} );
}
}
return PCI_EAT_NONE;
}
sub S_notice {
my ($self,$irc) = splice @_, 0, 2;
my ($who) = lc ${ $_[0] };
my ($what) = ${ $_[2] };
if ( $who eq lc $QFULL ) {
$self->_qbot_notice( $what );
return PCI_EAT_NONE;
}
return PCI_EAT_NONE;
}
sub _qbot_notice {
my ($self,$what) = splice @_, 0, 2;
SWITCH: {
if ( $what =~ /^AUTH\'d/i ) {
$self->{authed} = 1;
$self->{irc}->_send_event( 'irc_qnet_authed' );
last SWITCH;
}
}
}
1;