line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TeleGramma::BotAction::Listen; |
2
|
|
|
|
|
|
|
$App::TeleGramma::BotAction::Listen::VERSION = '0.12'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Base class for bot actions that listen |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
24
|
use Mojo::Base 'App::TeleGramma::BotAction'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
23
|
|
6
|
4
|
|
|
4
|
|
409
|
use App::TeleGramma::Constants qw/:const/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1176
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'command'; |
9
|
|
|
|
|
|
|
has 'response'; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
0
|
0
|
0
|
sub can_listen { 1 } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub process_message { |
14
|
7
|
|
|
7
|
0
|
70
|
my $self = shift; |
15
|
7
|
|
|
|
|
14
|
my $msg = shift; |
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
|
|
19
|
my $cmd = $self->command; |
18
|
|
|
|
|
|
|
|
19
|
7
|
50
|
33
|
|
|
37
|
if ($msg->text && ! ref($cmd) && $msg->text =~ /^\Q$cmd\E \b @?/x) { |
|
|
|
33
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
my ($body) = ($msg->text =~ /^ \S+ \s+ (.*)$/x); |
21
|
0
|
0
|
|
|
|
0
|
return $self->response->($msg, $body) if defined $body; # return body of command, if it existed |
22
|
0
|
|
|
|
|
0
|
return $self->response->($msg); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
7
|
100
|
33
|
|
|
68
|
if ($msg->text && ref($cmd) eq 'Regexp' && $msg->text =~ $cmd) { |
|
|
|
66
|
|
|
|
|
26
|
5
|
|
|
|
|
119
|
my $body = ($msg->text); |
27
|
5
|
50
|
|
|
|
33
|
return $self->response->($msg, $body) if defined $body; # return body of command, if it existed |
28
|
0
|
|
|
|
|
0
|
return $self->response->($msg); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
32
|
return PLUGIN_DECLINED; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=encoding UTF-8 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
App::TeleGramma::BotAction::Listen - Base class for bot actions that listen |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 VERSION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
version 0.12 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 AUTHOR |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Justin Hawkins <justin@eatmorecode.com> |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Justin Hawkins <justin@eatmorecode.com>. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
59
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |