line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Message; |
2
|
|
|
|
|
|
|
$Hubot::Message::VERSION = '0.2.7'; |
3
|
1
|
|
|
1
|
|
24453
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use namespace::autoclean; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'user' => ( is => 'ro', isa => 'Hubot::User', ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'done' => ( is => 'rw', isa => 'Bool', default => 0, ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub finish { shift->done(1) } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub TO_JSON { |
13
|
|
|
|
|
|
|
my $self = shift; |
14
|
|
|
|
|
|
|
return { |
15
|
|
|
|
|
|
|
## prvent recursive call |
16
|
|
|
|
|
|
|
## Hubot::UserTO_JSON -> Hubot::Message::TO_JSON -> Hubot::User::TO_JSON |
17
|
|
|
|
|
|
|
user => { name => $self->user->{name}, id => $self->user->{id}, }, |
18
|
|
|
|
|
|
|
done => $self->done, |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Hubot::TextMessage; |
27
|
|
|
|
|
|
|
$Hubot::TextMessage::VERSION = '0.2.7'; |
28
|
|
|
|
|
|
|
use Moose; |
29
|
|
|
|
|
|
|
use namespace::autoclean; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
extends 'Hubot::Message'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'text' => ( is => 'ro', isa => 'Str', ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub match { |
36
|
|
|
|
|
|
|
my ( $self, $regex ) = @_; |
37
|
|
|
|
|
|
|
return $self->text =~ m/$regex/; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
override 'TO_JSON' => sub { |
41
|
|
|
|
|
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
return { %{ super() }, text => $self->text }; |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
package Hubot::EnterMessage; |
50
|
|
|
|
|
|
|
$Hubot::EnterMessage::VERSION = '0.2.7'; |
51
|
|
|
|
|
|
|
use Moose; |
52
|
|
|
|
|
|
|
use namespace::autoclean; |
53
|
|
|
|
|
|
|
extends 'Hubot::Message'; |
54
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
package Hubot::LeaveMessage; |
59
|
|
|
|
|
|
|
$Hubot::LeaveMessage::VERSION = '0.2.7'; |
60
|
|
|
|
|
|
|
use Moose; |
61
|
|
|
|
|
|
|
use namespace::autoclean; |
62
|
|
|
|
|
|
|
extends 'Hubot::Message'; |
63
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
package Hubot::WhisperMessage; |
68
|
|
|
|
|
|
|
$Hubot::WhisperMessage::VERSION = '0.2.7'; |
69
|
|
|
|
|
|
|
use Moose; |
70
|
|
|
|
|
|
|
use namespace::autoclean; |
71
|
|
|
|
|
|
|
extends 'Hubot::TextMessage'; |
72
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
package Hubot::NoticeMessage; |
77
|
|
|
|
|
|
|
$Hubot::NoticeMessage::VERSION = '0.2.7'; |
78
|
|
|
|
|
|
|
use Moose; |
79
|
|
|
|
|
|
|
use namespace::autoclean; |
80
|
|
|
|
|
|
|
extends 'Hubot::TextMessage'; |
81
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
package Hubot::CatchAllMessage; |
86
|
|
|
|
|
|
|
$Hubot::CatchAllMessage::VERSION = '0.2.7'; |
87
|
|
|
|
|
|
|
use Moose; |
88
|
|
|
|
|
|
|
use namespace::autoclean; |
89
|
|
|
|
|
|
|
extends 'Hubot::Message'; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has 'message' => ( is => 'ro', isa => 'Hubot::Message' ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=pod |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=encoding utf-8 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 NAME |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Hubot::Message |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 VERSION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
version 0.2.7 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SYNOPSIS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $msg = Hubot::Message->new( |
112
|
|
|
|
|
|
|
user => $user # $user is Hubot::User |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$msg = Hubot::TextMessage->new( |
116
|
|
|
|
|
|
|
user => $user # $user is Hubot::User |
117
|
|
|
|
|
|
|
text => 'hi' |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$msg->finish; # this message is processed. |
121
|
|
|
|
|
|
|
# Hubot::Script::* will ignore this message. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DESCRIPTION |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Hubot::Adapter::* will make L<Hubot::Message> stand on input. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Hyungsuk Hong <hshong@perl.kr> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Hyungsuk Hong. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
136
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |