line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::IRC::Message; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::IRC::Message::VERSION = '0.021001'; |
3
|
|
|
|
|
|
|
## Message class. Inherits from Event |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
12996
|
use v5.10; |
|
5
|
|
|
|
|
12
|
|
6
|
5
|
|
|
5
|
|
395
|
use strictures 2; |
|
5
|
|
|
|
|
1115
|
|
|
5
|
|
|
|
|
134
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
1025
|
use Bot::Cobalt::Common; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
26
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
431
|
use Moo; |
|
5
|
|
|
|
|
5767
|
|
|
5
|
|
|
|
|
22
|
|
11
|
|
|
|
|
|
|
extends 'Bot::Cobalt::IRC::Event'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has message => ( |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => Str, |
17
|
|
|
|
|
|
|
trigger => sub { |
18
|
|
|
|
|
|
|
my ($self, $value) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$self->_set_stripped( |
21
|
|
|
|
|
|
|
strip_color( strip_formatting($value) ) |
22
|
|
|
|
|
|
|
) if $self->has_stripped; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
if ($self->has_message_array) { |
25
|
|
|
|
|
|
|
$self->message_array([ split ' ', $self->stripped ]); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has targets => ( |
31
|
|
|
|
|
|
|
required => 1, |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
isa => ArrayObj, |
34
|
|
|
|
|
|
|
coerce => 1, |
35
|
|
|
|
|
|
|
trigger => sub { |
36
|
|
|
|
|
|
|
my ($self, $value) = @_; |
37
|
|
|
|
|
|
|
$self->_set_target($value->[0]) if $self->has_target; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has target => ( |
42
|
|
|
|
|
|
|
lazy => 1, |
43
|
|
|
|
|
|
|
is => 'rwp', |
44
|
|
|
|
|
|
|
isa => Str, |
45
|
|
|
|
|
|
|
predicate => 'has_target', |
46
|
|
|
|
|
|
|
default => sub { $_[0]->targets->[0] }, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
## May or may not have a channel. |
50
|
|
|
|
|
|
|
has channel => ( |
51
|
|
|
|
|
|
|
lazy => 1, |
52
|
|
|
|
|
|
|
is => 'rw', |
53
|
|
|
|
|
|
|
isa => Str, |
54
|
|
|
|
|
|
|
default => sub { |
55
|
|
|
|
|
|
|
$_[0]->target =~ /^[#&+!]/ ? $_[0]->target : '' |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
## Message content. |
60
|
|
|
|
|
|
|
has stripped => ( |
61
|
|
|
|
|
|
|
lazy => 1, |
62
|
|
|
|
|
|
|
is => 'rwp', |
63
|
|
|
|
|
|
|
isa => Str, |
64
|
|
|
|
|
|
|
predicate => 'has_stripped', |
65
|
|
|
|
|
|
|
default => sub { |
66
|
|
|
|
|
|
|
strip_color( strip_formatting($_[0]->message) ) |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has message_array => ( |
71
|
|
|
|
|
|
|
lazy => 1, |
72
|
|
|
|
|
|
|
is => 'rw', |
73
|
|
|
|
|
|
|
isa => ArrayObj, |
74
|
|
|
|
|
|
|
coerce => 1, |
75
|
|
|
|
|
|
|
predicate => 'has_message_array', |
76
|
|
|
|
|
|
|
default => sub { [ split ' ', $_[0]->stripped ] }, |
77
|
|
|
|
|
|
|
trigger => sub { |
78
|
|
|
|
|
|
|
my ($self) = @_; |
79
|
|
|
|
|
|
|
if ($self->has_message_array_sp) { |
80
|
|
|
|
|
|
|
$self->_set_message_array_sp([ split / /, $self->stripped ]); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
}, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has message_array_sp => ( |
86
|
|
|
|
|
|
|
lazy => 1, |
87
|
|
|
|
|
|
|
is => 'rwp', |
88
|
|
|
|
|
|
|
isa => ArrayObj, |
89
|
|
|
|
|
|
|
coerce => 1, |
90
|
|
|
|
|
|
|
predicate => 'has_message_array_sp', |
91
|
|
|
|
|
|
|
default => sub { [ split / /, $_[0]->stripped ] }, |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
__END__ |