our
$AUTHORITY
=
'cpan:HINRIK'
;
$POE::Component::IRC::Plugin::ISupport::VERSION
=
'6.93'
;
sub
new {
return
bless
{ },
shift
;
}
sub
PCI_register {
my
(
$self
,
$irc
) =
splice
@_
, 0, 2;
$irc
->plugin_register(
$self
=>
SERVER
=>
qw(all)
);
$self
->{irc} =
$irc
;
$self
->{parser} = {
CASEMAPPING
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
$support
->{
$key
} =
$val
;
},
CHANLIMIT
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
while
(
$val
=~ /([^:]+):(\d+),?/g) {
my
(
$k
,
$v
) = ($1, $2);
@{
$support
->{
$key
} }{
split
(//,
$k
) } = (
$v
) x
length
$k
;
}
},
CHANMODES
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
$support
->{
$key
} = [
split
(/,/,
$val
) ];
},
CHANTYPES
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
$support
->{
$key
} = [
split
(//,
$val
) ];
},
ELIST
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
$support
->{
$key
} = [
split
(//,
$val
) ];
},
IDCHAN
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
while
(
$val
=~ /([^:]+):(\d+),?/g) {
my
(
$k
,
$v
) = ($1, $2);
@{
$support
->{
$key
} }{
split
(//,
$k
) } = (
$v
) x
length
$k
;
}
},
MAXLIST
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
while
(
$val
=~ /([^:]+):(\d+),?/g) {
my
(
$k
,
$v
) = ($1, $2);
@{
$support
->{
$key
} }{
split
(//,
$k
) } = (
$v
) x
length
$k
;
}
},
PREFIX
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
if
(
my
(
$k
,
$v
) =
$val
=~ /\(([^)]+)\)(.*)/ ) {
@{
$support
->{
$key
} }{
split
(//,
$k
) } =
split
(//,
$v
);
}
},
STATUSMSG
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
$support
->{
$key
} = [
split
(//,
$val
) ];
},
TARGMAX
=>
sub
{
my
(
$support
,
$key
,
$val
) =
@_
;
while
(
$val
=~ /([^:]+):(\d*),?/g) {
my
(
$k
,
$v
) = ($1, $2);
$support
->{
$key
}->{
$k
} =
$v
;
}
},
EXCEPTS
=>
sub
{
my
(
$support
,
$flag
) =
@_
;
$support
->{
$flag
} =
'e'
;
},
INVEX
=>
sub
{
my
(
$support
,
$flag
) =
@_
;
$support
->{
$flag
} =
'I'
;
},
};
return
1;
}
sub
PCI_unregister {
my
(
$self
,
$irc
) =
splice
@_
, 0, 2;
delete
$self
->{irc};
return
1;
}
sub
S_connected {
my
(
$self
,
$irc
) =
splice
@_
, 0, 2;
$self
->{server} = { };
$self
->{got_005} = 0;
$self
->{done_005} = 0;
return
PCI_EAT_NONE;
}
sub
S_005 {
my
(
$self
,
$irc
,
@args
) =
@_
;
my
@vals
= @{ ${
$args
[2] } };
pop
@vals
;
my
$support
=
$self
->{server};
for
my
$val
(
@vals
) {
if
(
$val
=~ /=/) {
my
$key
;
(
$key
,
$val
) =
split
(/=/,
$val
, 2);
if
(
defined
$self
->{parser}->{
$key
}) {
$self
->{parser}->{
$key
}->(
$support
,
$key
,
$val
);
}
else
{
$support
->{
$key
} =
$val
;
}
}
else
{
if
(
defined
$self
->{parser}->{
$val
}) {
$self
->{parser}->{
$val
}->(
$support
,
$val
);
}
else
{
$support
->{
$val
} =
'on'
;
}
}
}
$self
->{got_005}++;
return
PCI_EAT_NONE;
}
sub
_default {
my
(
$self
,
$irc
,
$event
) =
@_
;
return
PCI_EAT_NONE
if
$self
->{done_005};
return
PCI_EAT_NONE
if
!
$self
->{got_005};
if
(
$event
=~ /^S_(\d+)/ and $1 > 5) {
$self
->{done_005} = 1;
$irc
->send_event_now(
irc_isupport
=>
$self
);
}
return
PCI_EAT_NONE;
}
sub
isupport {
my
$self
=
shift
;
my
$value
=
uc
(
$_
[0] ) ||
return
;
return
$self
->{server}->{
$value
}
if
defined
$self
->{server}->{
$value
};
return
;
}
sub
isupport_dump_keys {
my
$self
=
shift
;
if
(
keys
%{
$self
->{server} } > 0 ) {
return
keys
%{
$self
->{server} };
}
return
;
}
1;