line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Component::IRC::Plugin::BotTraffic; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:HINRIK'; |
3
|
|
|
|
|
|
|
$POE::Component::IRC::Plugin::BotTraffic::VERSION = '6.91'; |
4
|
8
|
|
|
8
|
|
1473
|
use strict; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
283
|
|
5
|
8
|
|
|
8
|
|
43
|
use warnings FATAL => 'all'; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
315
|
|
6
|
8
|
|
|
8
|
|
40
|
use POE::Component::IRC::Plugin qw( :ALL ); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
978
|
|
7
|
8
|
|
|
8
|
|
45
|
use POE::Filter::IRCD; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
257
|
|
8
|
8
|
|
|
8
|
|
80
|
use POE::Filter::IRC::Compat; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
4211
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
7
|
|
|
7
|
1
|
2103
|
my ($package) = @_; |
12
|
7
|
|
|
|
|
81
|
return bless { }, $package; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub PCI_register { |
16
|
7
|
|
|
7
|
0
|
1302
|
my ($self, $irc) = splice @_, 0, 2; |
17
|
|
|
|
|
|
|
|
18
|
7
|
|
|
|
|
35
|
$self->{filter} = POE::Filter::IRCD->new(); |
19
|
7
|
|
|
|
|
154
|
$self->{compat} = POE::Filter::IRC::Compat->new(); |
20
|
7
|
|
|
|
|
37
|
$irc->plugin_register( $self, 'USER', qw(privmsg notice) ); |
21
|
7
|
|
|
|
|
264
|
return 1; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub PCI_unregister { |
25
|
7
|
|
|
7
|
0
|
1677
|
return 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub U_notice { |
29
|
2
|
|
|
2
|
0
|
166
|
my ($self, $irc) = splice @_, 0, 2; |
30
|
2
|
|
|
|
|
6
|
my $output = ${ $_[0] }; |
|
2
|
|
|
|
|
6
|
|
31
|
2
|
|
|
|
|
11
|
my $line = $self->{filter}->get([ $output ])->[0]; |
32
|
2
|
|
|
|
|
82
|
my $text = $line->{params}->[1]; |
33
|
2
|
|
|
|
|
7
|
my $targets = [ split(/,/, $line->{params}->[0]) ]; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
10
|
$irc->send_event_next(irc_bot_notice => $targets => $text); |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
39
|
return PCI_EAT_NONE; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub U_privmsg { |
41
|
6
|
|
|
6
|
0
|
530
|
my ($self, $irc) = splice @_, 0, 2; |
42
|
6
|
|
|
|
|
11
|
my $output = ${ $_[0] }; |
|
6
|
|
|
|
|
26
|
|
43
|
6
|
|
|
|
|
37
|
my $line = $self->{filter}->get([ $output ])->[0]; |
44
|
6
|
|
|
|
|
281
|
my $text = $line->{params}->[1]; |
45
|
|
|
|
|
|
|
|
46
|
6
|
100
|
|
|
|
23
|
if ($text =~ /^\001/) { |
47
|
3
|
|
|
|
|
37
|
my $ctcp_event = $self->{compat}->get([$line])->[0]; |
48
|
3
|
100
|
|
|
|
35
|
return PCI_EAT_NONE if $ctcp_event->{name} ne 'ctcp_action'; |
49
|
2
|
|
|
|
|
6
|
$irc->send_event_next(irc_bot_action => @{ $ctcp_event->{args} }[1..2]); |
|
2
|
|
|
|
|
9
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
3
|
50
|
|
|
|
5
|
my $chantypes = join('', @{ $irc->isupport('CHANTYPES') || ['#', '&']}); |
|
3
|
|
|
|
|
13
|
|
53
|
3
|
|
|
|
|
12
|
for my $recipient ( split(/,/, $line->{params}->[0]) ) { |
54
|
3
|
|
|
|
|
6
|
my $event = 'irc_bot_msg'; |
55
|
3
|
100
|
|
|
|
42
|
$event = 'irc_bot_public' if $recipient =~ /^[$chantypes]/; |
56
|
3
|
|
|
|
|
18
|
$irc->send_event_next($event => [ $recipient ] => $text); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
114
|
return PCI_EAT_NONE; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding utf8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
POE::Component::IRC::Plugin::BotTraffic - A PoCo-IRC plugin that generates |
70
|
|
|
|
|
|
|
events when you send messages |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SYNOPSIS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
use POE::Component::IRC::Plugin::BotTraffic; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$irc->plugin_add( 'BotTraffic', POE::Component::IRC::Plugin::BotTraffic->new() ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub irc_bot_public { |
79
|
|
|
|
|
|
|
my ($kernel, $heap) = @_[KERNEL, HEAP]; |
80
|
|
|
|
|
|
|
my $channel = $_[ARG0]->[0]; |
81
|
|
|
|
|
|
|
my $what = $_[ARG1]; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
print "I said '$what' on channel $channel\n"; |
84
|
|
|
|
|
|
|
return; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 DESCRIPTION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
POE::Component::IRC::Plugin::BotTraffic is a L |
90
|
|
|
|
|
|
|
plugin. It watches for when your bot sends PRIVMSGs and NOTICEs to the server |
91
|
|
|
|
|
|
|
and generates the appropriate events. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
These events are useful for logging what your bot says. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
No arguments required. Returns a plugin object suitable for feeding to |
100
|
|
|
|
|
|
|
L's C method. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 OUTPUT EVENTS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
These are the events generated by the plugin. Both events have C set |
105
|
|
|
|
|
|
|
to an arrayref of recipients and C the text that was sent. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 C |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
C will be an arrayref of recipients. C will be the text sent. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 C |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
C will be an arrayref of recipients. C will be the text sent. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 C |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
C will be an arrayref of recipients. C will be the text sent. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
C will be an arrayref of recipients. C will be the text sent. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Chris 'BinGOs' Williams [chris@bingosnet.co.uk] |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 SEE ALSO |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |