| 1 | package POE::Component::IRC::Plugin::Logger; | ||||||||||||||||||||||||||||
| 2 | 6 | $POE::Component::IRC::Plugin::Logger::VERSION = '6.95'; | |||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Encode::Guess; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Fcntl qw(O_WRONLY O_APPEND O_CREAT); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use File::Glob ':glob'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use File::Spec::Functions qw(catdir catfile rel2abs); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use IRC::Utils qw(lc_irc parse_user strip_color strip_formatting decode_irc); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use POE::Component::IRC::Plugin qw( :ALL ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use POE::Component::IRC::Plugin::BotTraffic; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use POSIX qw(strftime); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 5 | my ($package) = shift; | |||||||||||||||||||||||||||
| 18 | 5 | ▶ | croak "$package requires an even number of arguments" if @_ & 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 5 | my %self = @_; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 5 | ▶ | if (!defined $self{Path} && ref $self{Log_sub} ne 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $self{"Path"} and ref $self{"Log_sub"} ne "CODE"
MC/DC0%0/2
not defined $self{"Path"} and ref $self{"Log_sub"} ne "CODE"
not defined $self{"Path"}
ref $self{"Log_sub"} ne "CODE"
Truth table66%2/3
not(A) and B
A= not defined $self{"Path"}B= ref $self{"Log_sub"} ne "CODE"
| |||||||||||||||||||||||||||||
| 22 | 0 | die "$package requires a Path"; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | 5 | return bless \%self, $package; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 5 | ▶ | sub PCI_register { | ||||||||||||||||||||||||||
|
Subroutine
PCI_register: called CC=12 SCAR=28.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 5 | my ($self, $irc) = @_; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 5 | ▶ | if (!$irc->isa('POE::Component::IRC::State')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | die __PACKAGE__ . ' requires PoCo::IRC::State or a subclass thereof'; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 5 | ▶ | if ( !grep { $_->isa('POE::Component::IRC::Plugin::BotTraffic') } values %{ $irc->plugin_list() } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 5 | $irc->plugin_add('BotTraffic', POE::Component::IRC::Plugin::BotTraffic->new()); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 5 | ▶ | if ($self->{Restricted}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | $self->{dir_perm} = oct 700; | |||||||||||||||||||||||||||
| 40 | 0 | $self->{file_perm} = oct 600; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||
| 43 | 5 | $self->{dir_perm} = oct 755; | |||||||||||||||||||||||||||
| 44 | 5 | $self->{file_perm} = oct 644; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 5 | ▶ | $self->{Path} = bsd_glob($self->{Path}) if ref $self->{Log_sub} ne 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 5 | ▶ | if (defined $self->{Path} && ! -d $self->{Path}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"Path"} and not -d $self->{"Path"}
MC/DC0%0/2
defined $self->{"Path"} and not -d $self->{"Path"}
defined $self->{"Path"}
not -d $self->{"Path"}
Truth table66%2/3
A and not(B)
A= defined $self->{"Path"}B= not -d $self->{"Path"}
| |||||||||||||||||||||||||||||
| 50 | mkdir $self->{Path}, $self->{dir_perm} | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | or die 'Cannot create directory ' . $self->{Path} . ": $!; aborted"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $self->{Path} = rel2abs($self->{Path}); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 5 | $self->{irc} = $irc; | |||||||||||||||||||||||||||
| 56 | 5 | $self->{logging} = { }; | |||||||||||||||||||||||||||
| 57 | 5 | ▶ | $self->{Private} = 1 if !defined $self->{Private}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 5 | ▶ | $self->{Public} = 1 if !defined $self->{Public}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 5 | ▶ | $self->{DCC} = 1 if !defined $self->{DCC}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 5 | ▶ | $self->{Format} = $self->default_format() if !defined $self->{Format}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 5 | $irc->plugin_register($self, 'SERVER', qw(001 332 333 chan_mode | |||||||||||||||||||||||||||
| 63 | ctcp_action bot_action bot_msg bot_public bot_notice join kick msg | ||||||||||||||||||||||||||||
| 64 | nick part public notice quit topic dcc_start dcc_chat dcc_done)); | ||||||||||||||||||||||||||||
| 65 | 5 | $irc->plugin_register($self, 'USER', 'dcc_chat'); | |||||||||||||||||||||||||||
| 66 | 5 | return 1; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 5 | ▶ | sub PCI_unregister { | ||||||||||||||||||||||||||
|
Subroutine
PCI_unregister: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 70 | 5 | return 1; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 4 | ▶ | sub S_001 { | ||||||||||||||||||||||||||
|
Subroutine
S_001: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 4 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 75 | 4 | $self->{logging} = { }; | |||||||||||||||||||||||||||
| 76 | 4 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub S_332 { | ||||||||||||||||||||||||||
|
Subroutine
S_332: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 81 | 0 | my $chan = decode_irc(${ $_[2] }->[0]); | |||||||||||||||||||||||||||
| 82 | 0 | my $topic = $self->_normalize(${ $_[2] }->[1]); | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # only log this if we were just joining the channel | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $self->_log_entry($chan, topic_is => $chan, $topic) if !$irc->channel_list($chan); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub S_333 { | ||||||||||||||||||||||||||
|
Subroutine
S_333: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 91 | 0 | my ($chan, $user, $time) = @{ ${ $_[2] } }; | |||||||||||||||||||||||||||
| 92 | 0 | $chan = decode_irc($chan); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | # only log this if we were just joining the channel | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $self->_log_entry($chan, topic_set_by => $chan, $user, $time) if !$irc->channel_list($chan); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 12 | ▶ | sub S_chan_mode { | ||||||||||||||||||||||||||
|
Subroutine
S_chan_mode: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 12 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 101 | 12 | pop @_; | |||||||||||||||||||||||||||
| 102 | 12 | my $nick = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 103 | 12 | my $chan = decode_irc(${ $_[1] }); | |||||||||||||||||||||||||||
| 104 | 12 | my $mode = ${ $_[2] }; | |||||||||||||||||||||||||||
| 105 | 12 | ▶ | my $arg = defined $_[3] ? ${ $_[3] } : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 12 | $self->_log_entry($chan, $mode => $nick, $arg); | |||||||||||||||||||||||||||
| 108 | 12 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 1 | ▶ | sub S_ctcp_action { | ||||||||||||||||||||||||||
|
Subroutine
S_ctcp_action: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 112 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 113 | 1 | my $sender = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 114 | 1 | my $recipients = ${ $_[1] }; | |||||||||||||||||||||||||||
| 115 | 1 | my $msg = $self->_normalize(${ $_[2] }); | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 1 | for my $recipient (@{ $recipients }) { | |||||||||||||||||||||||||||
| 118 | 1 | ▶ | if ($recipient eq $irc->nick_name()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 1 | $self->_log_entry($sender, action => $sender, $msg); | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | else { | ||||||||||||||||||||||||||||
| 122 | 0 | $recipient = decode_irc($recipient); | |||||||||||||||||||||||||||
| 123 | 0 | $self->_log_entry($recipient, action => $sender, $msg); | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 2 | ▶ | sub S_notice { | ||||||||||||||||||||||||||
|
Subroutine
S_notice: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 130 | 2 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 131 | 2 | my $sender = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 132 | 2 | my $targets = ${ $_[1] }; | |||||||||||||||||||||||||||
| 133 | 2 | my $msg = $self->_normalize(${ $_[2] }); | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 2 | for my $target (@{ $targets }) { | |||||||||||||||||||||||||||
| 136 | 2 | ▶ | if ($target eq $irc->nick_name()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 1 | $self->_log_entry($sender, notice => $sender, $msg); | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | else { | ||||||||||||||||||||||||||||
| 140 | 1 | $target = decode_irc($target); | |||||||||||||||||||||||||||
| 141 | 1 | $self->_log_entry($target, notice => $sender, $msg); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 2 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 1 | ▶ | sub S_bot_action { | ||||||||||||||||||||||||||
|
Subroutine
S_bot_action: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 150 | 1 | my $recipients = ${ $_[0] }; | |||||||||||||||||||||||||||
| 151 | 1 | my $msg = $self->_normalize(${ $_[1] }); | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 1 | for my $recipient (@{ $recipients }) { | |||||||||||||||||||||||||||
| 154 | 1 | $recipient = decode_irc($recipient); | |||||||||||||||||||||||||||
| 155 | 1 | $self->_log_entry($recipient, action => $irc->nick_name(), $msg); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 1 | ▶ | sub S_bot_msg { | ||||||||||||||||||||||||||
|
Subroutine
S_bot_msg: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 161 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 162 | 1 | my $recipients = ${ $_[0] }; | |||||||||||||||||||||||||||
| 163 | 1 | my $msg = $self->_normalize(${ $_[1] }); | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 1 | for my $recipient (@{ $recipients }) { | |||||||||||||||||||||||||||
| 166 | 1 | $self->_log_entry($recipient, privmsg => $irc->nick_name(), $msg); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub S_bot_public { | ||||||||||||||||||||||||||
|
Subroutine
S_bot_public: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 172 | 0 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 173 | 0 | my $channels = ${ $_[0] }; | |||||||||||||||||||||||||||
| 174 | 0 | my $msg = $self->_normalize(${ $_[1] }); | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | for my $chan (@{ $channels }) { | |||||||||||||||||||||||||||
| 177 | 0 | $chan = decode_irc($chan); | |||||||||||||||||||||||||||
| 178 | 0 | $self->_log_entry($chan, privmsg => $irc->nick_name(), $msg); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 0 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 1 | ▶ | sub S_bot_notice { | ||||||||||||||||||||||||||
|
Subroutine
S_bot_notice: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 184 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 185 | 1 | my $targets = ${ $_[0] }; | |||||||||||||||||||||||||||
| 186 | 1 | my $msg = $self->_normalize(${ $_[1] }); | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 1 | for my $target (@{ $targets }) { | |||||||||||||||||||||||||||
| 189 | 1 | $target = decode_irc($target); | |||||||||||||||||||||||||||
| 190 | 1 | $self->_log_entry($target, notice => $irc->nick_name(), $msg); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 4 | ▶ | sub S_join { | ||||||||||||||||||||||||||
|
Subroutine
S_join: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 196 | 4 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 197 | 4 | my ($joiner, $user, $host) = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 198 | 4 | my $chan = decode_irc(${ $_[1] }); | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 4 | $self->_log_entry($chan, join => $joiner, "$user\@$host", $chan); | |||||||||||||||||||||||||||
| 201 | 4 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 1 | ▶ | sub S_kick { | ||||||||||||||||||||||||||
|
Subroutine
S_kick: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 205 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 206 | 1 | my $kicker = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 207 | 1 | my $chan = decode_irc(${ $_[1] }); | |||||||||||||||||||||||||||
| 208 | 1 | my $victim = ${ $_[2] }; | |||||||||||||||||||||||||||
| 209 | 1 | my $msg = $self->_normalize(${ $_[3] }); | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 1 | $self->_log_entry($chan, kick => $kicker, $victim, $chan, $msg); | |||||||||||||||||||||||||||
| 212 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 1 | ▶ | sub S_msg { | ||||||||||||||||||||||||||
|
Subroutine
S_msg: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 216 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 217 | 1 | my $sender = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 218 | 1 | my $msg = $self->_normalize(${ $_[2] }); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 1 | $self->_log_entry($sender, privmsg => $sender, $msg); | |||||||||||||||||||||||||||
| 221 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 1 | ▶ | sub S_nick { | ||||||||||||||||||||||||||
|
Subroutine
S_nick: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 225 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 226 | 1 | my $old_nick = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 227 | 1 | my $new_nick = ${ $_[1] }; | |||||||||||||||||||||||||||
| 228 | 1 | my $channels = ${ $_[2] }; | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 1 | for my $chan (@{ $channels }) { | |||||||||||||||||||||||||||
| 231 | 1 | $chan = decode_irc($chan); | |||||||||||||||||||||||||||
| 232 | 1 | $self->_log_entry($chan, nick_change => $old_nick, $new_nick); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 1 | ▶ | sub S_part { | ||||||||||||||||||||||||||
|
Subroutine
S_part: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 238 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 239 | 1 | my ($parter, $user, $host) = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 240 | 1 | my $chan = decode_irc(${ $_[1] }); | |||||||||||||||||||||||||||
| 241 | 1 | ▶ | my $msg = ref $_[2] eq 'SCALAR' ? ${ $_[2] } : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 1 | $msg = $self->_normalize($msg); | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 1 | $self->_log_entry($chan, part => $parter, "$user\@$host", $chan, $msg); | |||||||||||||||||||||||||||
| 245 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 1 | ▶ | sub S_public { | ||||||||||||||||||||||||||
|
Subroutine
S_public: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 249 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 250 | 1 | my $sender = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 251 | 1 | my $channels = ${ $_[1] }; | |||||||||||||||||||||||||||
| 252 | 1 | my $msg = $self->_normalize(${ $_[2] }); | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 1 | for my $chan (@{ $channels }) { | |||||||||||||||||||||||||||
| 255 | 1 | $chan = decode_irc($chan); | |||||||||||||||||||||||||||
| 256 | 1 | $self->_log_entry($chan, privmsg => $sender, $msg); | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 1 | ▶ | sub S_quit { | ||||||||||||||||||||||||||
|
Subroutine
S_quit: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 262 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 263 | 1 | my ($quitter, $user, $host) = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 264 | 1 | my $msg = $self->_normalize(${ $_[1] }); | |||||||||||||||||||||||||||
| 265 | 1 | my $channels = ${ $_[2] }; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 1 | for my $chan (@{ $channels }) { | |||||||||||||||||||||||||||
| 268 | 1 | $chan = decode_irc($chan); | |||||||||||||||||||||||||||
| 269 | 1 | $self->_log_entry($chan, quit => $quitter, "$user\@$host", $msg); | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 1 | ▶ | sub S_topic { | ||||||||||||||||||||||||||
|
Subroutine
S_topic: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 275 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 276 | 1 | my $changer = parse_user(${ $_[0] }); | |||||||||||||||||||||||||||
| 277 | 1 | my $chan = decode_irc(${ $_[1] }); | |||||||||||||||||||||||||||
| 278 | 1 | my $new_topic = $self->_normalize(${ $_[2] }); | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 1 | $self->_log_entry($chan, topic_change => $changer, $new_topic); | |||||||||||||||||||||||||||
| 281 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 1 | ▶ | sub S_dcc_start { | ||||||||||||||||||||||||||
|
Subroutine
S_dcc_start: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 285 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 286 | 1 | my $nick = ${ $_[1] }; | |||||||||||||||||||||||||||
| 287 | 1 | my $type = ${ $_[2] }; | |||||||||||||||||||||||||||
| 288 | 1 | my $port = ${ $_[3] }; | |||||||||||||||||||||||||||
| 289 | 1 | my $addr = ${ $_[6] }; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 1 | ▶ | return PCI_EAT_NONE if $type ne 'CHAT'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | 1 | $self->_log_entry("=$nick", dcc_start => $nick, "$addr:$port"); | |||||||||||||||||||||||||||
| 293 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 2 | ▶ | sub S_dcc_chat { | ||||||||||||||||||||||||||
|
Subroutine
S_dcc_chat: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 297 | 2 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 298 | 2 | my $nick = ${ $_[1] }; | |||||||||||||||||||||||||||
| 299 | 2 | my $msg = $self->_normalize(${ $_[3] }); | |||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 2 | ▶ | if (my ($action) = $msg =~ /\001ACTION (.*?)\001/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 1 | $self->_log_entry("=$nick", action => $nick, $action); | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | else { | ||||||||||||||||||||||||||||
| 305 | 1 | $self->_log_entry("=$nick", privmsg => $nick, $msg); | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | 2 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 2 | ▶ | sub U_dcc_chat { | ||||||||||||||||||||||||||
|
Subroutine
U_dcc_chat: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 311 | 2 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 312 | 2 | pop @_; | |||||||||||||||||||||||||||
| 313 | 2 | my ($id, @lines) = @_; | |||||||||||||||||||||||||||
| 314 | 2 | $_ = $$_ for @lines; | |||||||||||||||||||||||||||
| 315 | 2 | my $me = $irc->nick_name(); | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 2 | my ($dcc) = grep { $_->isa('POE::Component::IRC::Plugin::DCC') } values %{ $irc->plugin_list() }; | |||||||||||||||||||||||||||
| 318 | 2 | my $info = $dcc->dcc_info($$id); | |||||||||||||||||||||||||||
| 319 | 2 | my $nick = $info->{nick}; | |||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 2 | for my $msg (@lines) { | |||||||||||||||||||||||||||
| 322 | 2 | $msg = $self->_normalize($msg); | |||||||||||||||||||||||||||
| 323 | 2 | ▶ | if (my ($action) = $msg =~ /\001ACTION (.*?)\001/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 1 | $self->_log_entry("=$nick", action => $me, $action); | |||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||
| 326 | else { | ||||||||||||||||||||||||||||
| 327 | 1 | $self->_log_entry("=$nick", privmsg => $me, $msg); | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | 2 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 1 | ▶ | sub S_dcc_done { | ||||||||||||||||||||||||||
|
Subroutine
S_dcc_done: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 334 | 1 | my ($self, $irc) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 335 | 1 | my $nick = ${ $_[1] }; | |||||||||||||||||||||||||||
| 336 | 1 | my $type = ${ $_[2] }; | |||||||||||||||||||||||||||
| 337 | 1 | my $port = ${ $_[3] }; | |||||||||||||||||||||||||||
| 338 | 1 | my $addr = ${ $_[7] }; | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 1 | ▶ | return PCI_EAT_NONE if $type ne 'CHAT'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 1 | $self->_log_entry("=$nick", dcc_done => $nick, "$addr:$port"); | |||||||||||||||||||||||||||
| 342 | 1 | return PCI_EAT_NONE; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 35 | ▶ | sub _log_entry { | ||||||||||||||||||||||||||
|
Subroutine
_log_entry: called CC=16 SCAR=30.7
| |||||||||||||||||||||||||||||
| 346 | 35 | my ($self, $context, $type, @args) = @_; | |||||||||||||||||||||||||||
| 347 | 35 | my ($date, $time) = split / /, (strftime '%Y-%m-%d %H:%M:%S ', localtime); | |||||||||||||||||||||||||||
| 348 | 35 | $context = lc_irc $context, $self->{irc}->isupport('CASEMAPPING'); | |||||||||||||||||||||||||||
| 349 | 35 | ▶ | my $chantypes = join('', @{ $self->{irc}->isupport('CHANTYPES') || ['#', '&']}); | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'irc'}->isupport('CHANTYPES') || ['#', '&']
MC/DC0%0/1
$self->{'irc'}->isupport('CHANTYPES') || ['#', '&']
$self->{'irc'}->isupport('CHANTYPES')
Truth table50%1/2
A
A= $self->{'irc'}->isupport('CHANTYPES')
| |||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 35 | ▶ | if ($context =~ /^[$chantypes]/) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 352 | 23 | ▶ | return if !$self->{Public}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | elsif ($context =~ /^=/) { | ||||||||||||||||||||||||||||
| 355 | 6 | ▶ | return if !$self->{DCC}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | else { | ||||||||||||||||||||||||||||
| 358 | 6 | ▶ | return if !$self->{Private}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 35 | ▶ | return if $type eq 'notice' && !$self->{Notices}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type eq "notice" and not $self->{"Notices"}
MC/DC0%0/2
$type eq "notice" and not $self->{"Notices"}
$type eq "notice"
not $self->{"Notices"}
Truth table66%2/3
A and not(B)
A= $type eq "notice"B= not $self->{"Notices"}
| |||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 35 | ▶ | if (ref $self->{Log_sub} eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | 3 | $self->{Log_sub}->($context, $type, @args); | |||||||||||||||||||||||||||
| 365 | 3 | return; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 32 | ▶ | return if !defined $self->{Format}->{$type}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | # slash is problematic in a filename, replace it with underscore | ||||||||||||||||||||||||||||
| 371 | 32 | $context =~ s!/!_!g; | |||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 32 | my $log_file; | |||||||||||||||||||||||||||
| 374 | 32 | ▶ | if ($self->{Sort_by_date}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 0 | my $log_dir = catdir($self->{Path}, $context); | |||||||||||||||||||||||||||
| 376 | 0 | ▶ | if (! -d $log_dir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | mkdir $log_dir, $self->{dir_perm} | ||||||||||||||||||||||||||||
| 378 | 0 | ▶ | or die "Couldn't create directory $log_dir: $!; aborted"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | 0 | $log_file = catfile($self->{Path}, $context, "$date.log"); | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | else { | ||||||||||||||||||||||||||||
| 383 | 32 | $log_file = catfile($self->{Path}, "$context.log"); | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 32 | $log_file = $self->_open_log($log_file); | |||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 32 | ▶ | if (!$self->{logging}->{$context}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 389 | 3 | print $log_file "***\n*** LOGGING BEGINS\n***\n"; | |||||||||||||||||||||||||||
| 390 | 3 | $self->{logging}->{$context} = 1; | |||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | 32 | my $line = "$time " . $self->{Format}->{$type}->(@args); | |||||||||||||||||||||||||||
| 393 | 32 | ▶ | $line = "$date $line" if !$self->{Sort_by_date}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 394 | 32 | print $log_file $line, "\n"; | |||||||||||||||||||||||||||
| 395 | 32 | return; | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 32 | ▶ | sub _open_log { | ||||||||||||||||||||||||||
|
Subroutine
_open_log: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 399 | 32 | my ($self, $file_name) = @_; | |||||||||||||||||||||||||||
| 400 | sysopen(my $log, $file_name, O_WRONLY|O_APPEND|O_CREAT, $self->{file_perm}) | ||||||||||||||||||||||||||||
| 401 | 32 | ▶ | or die "Couldn't open or create file '$file_name': $!; aborted"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 402 | 32 | binmode($log, ':encoding(utf8)'); | |||||||||||||||||||||||||||
| 403 | 32 | $log->autoflush(1); | |||||||||||||||||||||||||||
| 404 | 32 | return $log; | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 16 | ▶ | sub _normalize { | ||||||||||||||||||||||||||
|
Subroutine
_normalize: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||
| 408 | 16 | my ($self, $line) = @_; | |||||||||||||||||||||||||||
| 409 | 16 | $line = decode_irc($line); | |||||||||||||||||||||||||||
| 410 | 16 | ▶ | $line = strip_color($line) if $self->{Strip_color}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | 16 | ▶ | $line = strip_formatting($line) if $self->{Strip_formatting}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 412 | 16 | return $line; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 5 | ▶ | sub default_format { | ||||||||||||||||||||||||||
|
Subroutine
default_format: called CC=1 SCAR=0.9
Pod
documented
| |||||||||||||||||||||||||||||
| 416 | return { | ||||||||||||||||||||||||||||
| 417 | 1 | ▶ | '+b' => sub { my ($nick, $mask) = @_; "--- $nick sets ban on $mask" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 418 | 1 | ▶ | '-b' => sub { my ($nick, $mask) = @_; "--- $nick removes ban on $mask" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 419 | 0 | ▶ | '+e' => sub { my ($nick, $mask) = @_; "--- $nick sets exempt on $mask" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 420 | 0 | ▶ | '-e' => sub { my ($nick, $mask) = @_; "--- $nick removes exempt on $mask" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 421 | 0 | ▶ | '+I' => sub { my ($nick, $mask) = @_; "--- $nick sets invite on $mask" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 422 | 0 | ▶ | '-I' => sub { my ($nick, $mask) = @_; "--- $nick removes invite on $mask" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | '+h' => sub { my ($nick, $subject) = @_; "--- $nick gives channel half-operator status to $subject" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 424 | 0 | ▶ | '-h' => sub { my ($nick, $subject) = @_; "--- $nick removes channel half-operator status from $subject" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 425 | 1 | ▶ | '+o' => sub { my ($nick, $subject) = @_; "--- $nick gives channel operator status to $subject" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 426 | 0 | ▶ | '-o' => sub { my ($nick, $subject) = @_; "--- $nick removes channel operator status from $subject" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 427 | 0 | ▶ | '+v' => sub { my ($nick, $subject) = @_; "--- $nick gives voice to $subject" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 428 | 0 | ▶ | '-v' => sub { my ($nick, $subject) = @_; "--- $nick removes voice from $subject" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 429 | 1 | ▶ | '+k' => sub { my ($nick, $key) = @_; "--- $nick sets channel keyword to $key" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 430 | 1 | ▶ | '-k' => sub { my ($nick) = @_; "--- $nick removes channel keyword" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 431 | 1 | ▶ | '+l' => sub { my ($nick, $limit) = @_; "--- $nick sets channel user limit to $limit" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 432 | 1 | ▶ | '-l' => sub { my ($nick) = @_; "--- $nick removes channel user limit" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 433 | 0 | ▶ | '+i' => sub { my ($nick) = @_; "--- $nick enables invite-only channel status" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 434 | 0 | ▶ | '-i' => sub { my ($nick) = @_; "--- $nick disables invite-only channel status" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 435 | 1 | ▶ | '+m' => sub { my ($nick) = @_; "--- $nick enables channel moderation" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 436 | 0 | ▶ | '-m' => sub { my ($nick) = @_; "--- $nick disables channel moderation" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 437 | 0 | ▶ | '+n' => sub { my ($nick) = @_; "--- $nick disables external messages" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 438 | 0 | ▶ | '-n' => sub { my ($nick) = @_; "--- $nick enables external messages" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 439 | 0 | ▶ | '+p' => sub { my ($nick) = @_; "--- $nick enables private channel status" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 440 | 0 | ▶ | '-p' => sub { my ($nick) = @_; "--- $nick disables private channel status" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 441 | 1 | ▶ | '+s' => sub { my ($nick) = @_; "--- $nick enables secret channel status" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 442 | 0 | ▶ | '-s' => sub { my ($nick) = @_; "--- $nick disables secret channel status" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 443 | 0 | ▶ | '+t' => sub { my ($nick) = @_; "--- $nick enables topic protection" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 444 | 1 | ▶ | '-t' => sub { my ($nick) = @_; "--- $nick disables topic protection" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 445 | 1 | ▶ | nick_change => sub { my ($old_nick, $new_nick) = @_; "--- $old_nick is now known as $new_nick" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 446 | 0 | ▶ | topic_is => sub { my ($chan, $topic) = @_; "--- Topic for $chan is: $topic" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 447 | 1 | ▶ | topic_change => sub { my ($nick, $topic) = @_; "--- $nick changes the topic to: $topic" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 448 | 5 | ▶ | privmsg => sub { my ($nick, $msg) = @_; "<$nick> $msg" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 449 | 3 | ▶ | notice => sub { my ($nick, $msg) = @_; ">$nick< $msg" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 450 | 4 | ▶ | action => sub { my ($nick, $action) = @_; "* $nick $action" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 451 | 1 | ▶ | dcc_start => sub { my ($nick, $address) = @_; "--> Opened DCC chat connection with $nick ($address)" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 452 | 1 | ▶ | dcc_done => sub { my ($nick, $address) = @_; "<-- Closed DCC chat connection with $nick ($address)" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 453 | 3 | ▶ | join => sub { my ($nick, $userhost, $chan) = @_; "--> $nick ($userhost) joins $chan" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 454 | 1 | ▶ | part => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 455 | 1 | my ($nick, $userhost, $chan, $msg) = @_; | |||||||||||||||||||||||||||
| 456 | 1 | my $line = "<-- $nick ($userhost) leaves $chan"; | |||||||||||||||||||||||||||
| 457 | 1 | ▶ | $line .= " ($msg)" if $msg ne ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 458 | 1 | return $line; | |||||||||||||||||||||||||||
| 459 | }, | ||||||||||||||||||||||||||||
| 460 | 1 | ▶ | quit => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 461 | 1 | my ($nick, $userhost, $msg) = @_; | |||||||||||||||||||||||||||
| 462 | 1 | my $line = "<-- $nick ($userhost) quits"; | |||||||||||||||||||||||||||
| 463 | 1 | ▶ | $line .= " ($msg)" if $msg ne ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 464 | 1 | return $line; | |||||||||||||||||||||||||||
| 465 | }, | ||||||||||||||||||||||||||||
| 466 | 1 | ▶ | kick => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 467 | 1 | my ($kicker, $victim, $chan, $msg) = @_; | |||||||||||||||||||||||||||
| 468 | 1 | my $line = "<-- $kicker kicks $victim from $chan"; | |||||||||||||||||||||||||||
| 469 | 1 | ▶ | $line .= " ($msg)" if $msg ne ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | 1 | return $line; | |||||||||||||||||||||||||||
| 471 | }, | ||||||||||||||||||||||||||||
| 472 | 0 | ▶ | topic_set_by => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 473 | 0 | my ($chan, $user, $time) = @_; | |||||||||||||||||||||||||||
| 474 | 0 | my $date = localtime $time; | |||||||||||||||||||||||||||
| 475 | 0 | return "--- Topic for $chan was set by $user at $date"; | |||||||||||||||||||||||||||
| 476 | }, | ||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | 5 | } | |||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 6 | 1; | |||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | =encoding utf8 | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | =head1 NAME | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | POE::Component::IRC::Plugin::Logger - A PoCo-IRC plugin which | ||||||||||||||||||||||||||||
| 487 | logs public, private, and DCC chat messages to disk | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | use POE::Component::IRC::Plugin::Logger; | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | $irc->plugin_add('Logger', POE::Component::IRC::Plugin::Logger->new( | ||||||||||||||||||||||||||||
| 494 | Path => '/home/me/irclogs', | ||||||||||||||||||||||||||||
| 495 | DCC => 0, | ||||||||||||||||||||||||||||
| 496 | Private => 0, | ||||||||||||||||||||||||||||
| 497 | Public => 1, | ||||||||||||||||||||||||||||
| 498 | )); | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | POE::Component::IRC::Plugin::Logger is a L<POE::Component::IRC|POE::Component::IRC> | ||||||||||||||||||||||||||||
| 503 | plugin. It logs messages and CTCP ACTIONs to either F<#some_channel.log> or | ||||||||||||||||||||||||||||
| 504 | F<some_nickname.log> in the supplied path. In the case of DCC chats, a '=' is | ||||||||||||||||||||||||||||
| 505 | prepended to the nickname (like in irssi). | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | The plugin tries to detect UTF-8 encoding of every message or else falls back | ||||||||||||||||||||||||||||
| 508 | to CP1252, like irssi (and, supposedly, mIRC) does by default. Resulting log | ||||||||||||||||||||||||||||
| 509 | files will be UTF-8 encoded. The default log format is similar to xchat's, | ||||||||||||||||||||||||||||
| 510 | except that it's sane and parsable. | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | This plugin requires the IRC component to be L<POE::Component::IRC::State|POE::Component::IRC::State> | ||||||||||||||||||||||||||||
| 513 | or a subclass thereof. It also requires a L<POE::Component::IRC::Plugin::BotTraffic|POE::Component::IRC::Plugin::BotTraffic> | ||||||||||||||||||||||||||||
| 514 | to be in the plugin pipeline. It will be added automatically if it is not | ||||||||||||||||||||||||||||
| 515 | present. | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | =head1 METHODS | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | =head2 C<new> | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | Arguments: | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | B<'Path'>, the place where you want the logs saved. | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | B<'Private'>, whether or not to log private messages. Defaults to 1. | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | B<'Public'>, whether or not to log public messages. Defaults to 1. | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | B<'DCC'>, whether or not to log DCC chats. Defaults to 1. | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | B<'Notices'>, whether or not to log NOTICEs. Defaults to 0. | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | B<'Sort_by_date'>, whether or not to split log files by date, i.e. | ||||||||||||||||||||||||||||
| 534 | F<#channel/YYYY-MM-DD.log> instead of F<#channel.log>. If enabled, the date | ||||||||||||||||||||||||||||
| 535 | will be omitted from the timestamp. Defaults to 0. | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | B<'Strip_color'>, whether or not to strip all color codes from messages. Defaults | ||||||||||||||||||||||||||||
| 538 | to 0. | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | B<'Strip_formatting'>, whether or not to strip all formatting codes from messages. | ||||||||||||||||||||||||||||
| 541 | Defaults to 0. | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | B<'Restricted'>, set this to 1 if you want all directories/files to be created | ||||||||||||||||||||||||||||
| 544 | without read permissions for other users (i.e. 700 for dirs and 600 for files). | ||||||||||||||||||||||||||||
| 545 | Defaults to 1. | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | B<'Format'>, a hash reference representing the log format, if you want to define | ||||||||||||||||||||||||||||
| 548 | your own. See the source for details. | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | B<'Log_sub'>, a subroutine reference which can be used to override the file | ||||||||||||||||||||||||||||
| 551 | logging. Use this if you want to store logs in a database instead, for | ||||||||||||||||||||||||||||
| 552 | example. It will be called with 3 arguments: the context (a channel name or | ||||||||||||||||||||||||||||
| 553 | nickname), a type (e.g. 'privmsg' or '+b', and any arguments to that type. | ||||||||||||||||||||||||||||
| 554 | You can make use L</default_format> to create logs that match the default | ||||||||||||||||||||||||||||
| 555 | log format. B<Note:> You must take care of handling date/time and stripping | ||||||||||||||||||||||||||||
| 556 | colors/formatting codes yourself. | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | Returns a plugin object suitable for feeding to | ||||||||||||||||||||||||||||
| 559 | L<POE::Component::IRC|POE::Component::IRC>'s C<plugin_add> method. | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | =head2 C<default_format> | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | Returns a hash reference of type/subroutine pairs, for formatting logs | ||||||||||||||||||||||||||||
| 564 | according to the default log format. | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | Hinrik E<Ouml>rn SigurE<eth>sson, hinrik.sig@gmail.com | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | =cut | ||||||||||||||||||||||||||||