| 1 | package POE::Component::IRC::Plugin::MultiProxy::Away; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | $POE::Component::IRC::Plugin::MultiProxy::Away::AUTHORITY = 'cpan:HINRIK'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | $POE::Component::IRC::Plugin::MultiProxy::Away::VERSION = '0.01'; | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use POE::Component::IRC::Plugin qw( :ALL ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | my ($package, %self) = @_; | |||||||||||||||||||||||||||
| 15 | 0 | return bless \%self, $package; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub PCI_register { | ||||||||||||||||||||||||||
|
Subroutine
PCI_register: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | my ($self, $irc) = @_; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if (!$irc->isa('POE::Component::IRC::State')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | die __PACKAGE__ . " requires PoCo::IRC::State or a subclass thereof\n"; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $self->{Message} = 'No clients attached' unless defined $self->{Message}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | $self->{clients} = 0; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($irc->connected() && $irc->is_away($irc->nick_name())) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$irc->connected and $irc->is_away($irc->nick_name)
MC/DC0%0/2
$irc->connected and $irc->is_away($irc->nick_name)
$irc->connected
$irc->is_away($irc->nick_name)
Truth table0%0/3
A and B
A= $irc->connectedB= $irc->is_away($irc->nick_name)
| |||||||||||||||||||||||||||||
| 29 | 0 | $self->{away} = 1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | $irc->plugin_register($self, 'SERVER', qw(001 proxy_authed proxy_close)); | |||||||||||||||||||||||||||
| 33 | 0 | return 1; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub PCI_unregister { | ||||||||||||||||||||||||||
|
Subroutine
PCI_unregister: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 0 | return 1; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub S_001 { | ||||||||||||||||||||||||||
|
Subroutine
S_001: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | if (!$self->{clients}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | $irc->yield(away => $self->{Message}); | |||||||||||||||||||||||||||
| 44 | 0 | $self->{away} = 1; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub S_proxy_authed { | ||||||||||||||||||||||||||
|
Subroutine
S_proxy_authed: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 51 | 0 | my $client = ${ $_[0] }; | |||||||||||||||||||||||||||
| 52 | 0 | $self->{clients}++; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($self->{away}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | $irc->yield('away'); | |||||||||||||||||||||||||||
| 55 | 0 | $self->{away} = 0; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub S_proxy_close { | ||||||||||||||||||||||||||
|
Subroutine
S_proxy_close: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 62 | 0 | my $client = ${ $_[0] }; | |||||||||||||||||||||||||||
| 63 | 0 | $self->{clients}--; | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | if (!$self->{clients}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | $irc->yield(away => $self->{Message}); | |||||||||||||||||||||||||||
| 66 | 0 | $self->{away} = 1; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub message { | ||||||||||||||||||||||||||
|
Subroutine
message: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | return $self->{Message} if !defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | $self->{Message} = $value; | |||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | 1; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =encoding utf8 | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 NAME | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | POE::Component::IRC::Plugin::MultiProxy::Away - A PoCo-IRC plugin which changes the away status based on the presence of proxy clients | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | use POE::Compoent::IRC::Plugin::MultiProxy::Away; | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | $irc->plugin_add('Away', POE::Compoent::IRC::Plugin::MultiProxy::Away->new(Message => "I'm out to lunch")); | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | POE::Compoent::IRC::Plugin::MultiProxy::Away is a | ||||||||||||||||||||||||||||
| 95 | L<POE::Component::IRC|POE::Component::IRC> plugin. When the last proxy clien | ||||||||||||||||||||||||||||
| 96 | detaches, it changes the status to away, with the supplied away message. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | This plugin requires the IRC component to be | ||||||||||||||||||||||||||||
| 99 | L<POE::Component::IRC::State|POE::Component::IRC::State> or a subclass thereof. | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head1 METHODS | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =head2 C<new> | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | One optional argument: | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | B<'Message'>, the away message you want to use. Defaults to 'No clients | ||||||||||||||||||||||||||||
| 108 | attached'. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | Returns a plugin object suitable for feeding to | ||||||||||||||||||||||||||||
| 111 | L<POE::Component::IRC|POE::Component::IRC>'s C<plugin_add()> method. | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head2 C<message> | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | One optional argument: | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | An away message | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | Changes the away message when called with an argument, returns the current | ||||||||||||||||||||||||||||
| 120 | away message otherwise. | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =cut | ||||||||||||||||||||||||||||