line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::IRC::Message::Public; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::IRC::Message::Public::VERSION = '0.021003'; |
3
|
5
|
|
|
5
|
|
1314
|
use v5.10; |
|
5
|
|
|
|
|
10
|
|
4
|
5
|
|
|
5
|
|
21
|
use strictures 2; |
|
5
|
|
|
|
|
33
|
|
|
5
|
|
|
|
|
166
|
|
5
|
5
|
|
|
5
|
|
819
|
use Scalar::Util 'blessed'; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
229
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
330
|
use Bot::Cobalt; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
27
|
|
8
|
5
|
|
|
5
|
|
3181
|
use Bot::Cobalt::Common; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Bot::Cobalt::Core; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
24
|
use Moo; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
30
|
|
13
|
|
|
|
|
|
|
extends 'Bot::Cobalt::IRC::Message'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has cmd => ( |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => Any, |
19
|
|
|
|
|
|
|
predicate => 'has_cmd', |
20
|
|
|
|
|
|
|
builder => '_build_cmd', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has highlight => ( |
24
|
|
|
|
|
|
|
lazy => 1, |
25
|
|
|
|
|
|
|
is => 'rw', |
26
|
|
|
|
|
|
|
isa => Bool, |
27
|
|
|
|
|
|
|
predicate => 'has_highlight', |
28
|
|
|
|
|
|
|
builder => '_build_highlight', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has myself => ( |
32
|
|
|
|
|
|
|
lazy => 1, |
33
|
|
|
|
|
|
|
is => 'rw', |
34
|
|
|
|
|
|
|
isa => Str, |
35
|
|
|
|
|
|
|
builder => sub { |
36
|
1
|
|
|
1
|
|
675
|
my ($self) = @_; |
37
|
1
|
|
|
|
|
1
|
my $irc; |
38
|
1
|
50
|
33
|
|
|
4
|
return '' |
39
|
|
|
|
|
|
|
unless Bot::Cobalt::Core->has_instance |
40
|
|
|
|
|
|
|
and $irc = irc_object($self->context); |
41
|
0
|
0
|
|
|
|
0
|
$irc->nick_name || '' |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
after message => sub { |
46
|
|
|
|
|
|
|
my ($self, $value) = @_; |
47
|
|
|
|
|
|
|
return unless defined $value; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
if ($self->has_highlight) { |
50
|
|
|
|
|
|
|
$self->highlight( $self->_build_highlight ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if ($self->has_cmd) { |
54
|
|
|
|
|
|
|
$self->cmd( $self->_build_cmd ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _build_highlight { |
59
|
2
|
|
|
2
|
|
1281
|
my ($self) = @_; |
60
|
2
|
|
100
|
|
|
16
|
my $me = $self->myself || return 0; |
61
|
1
|
|
|
|
|
18
|
my $txt = $self->stripped; |
62
|
1
|
|
|
|
|
40
|
$txt =~ /^${me}[,:;!-]?\s+/i |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _build_cmd { |
66
|
3
|
|
|
3
|
|
988
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $cmdchar = Bot::Cobalt::Core->has_instance ? |
69
|
3
|
50
|
0
|
|
|
14
|
(core->get_core_cfg->opts->{CmdChar} // '!') : '!' |
70
|
|
|
|
|
|
|
; |
71
|
|
|
|
|
|
|
|
72
|
3
|
100
|
|
|
|
47
|
if ($self->stripped =~ /^${cmdchar}([^\s]+)/) { |
73
|
1
|
|
|
|
|
109
|
my $message = $self->message_array; |
74
|
1
|
|
|
|
|
88
|
shift @$message; |
75
|
|
|
|
|
|
|
# shift above modifies the ref, but intentionally hit trigger: |
76
|
1
|
|
|
|
|
14
|
$self->message_array($message); |
77
|
1
|
|
|
|
|
17
|
return lc($1) |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
undef |
80
|
2
|
|
|
|
|
40
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
__END__ |