line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TeleGramma::Plugin::Core::Thants; |
2
|
|
|
|
|
|
|
$App::TeleGramma::Plugin::Core::Thants::VERSION = '0.12'; |
3
|
|
|
|
|
|
|
# ABSTRACT: TeleGramma plugin to give thants where necessary |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2006
|
use Mojo::Base 'App::TeleGramma::Plugin::Base'; |
|
2
|
|
|
|
|
6846
|
|
|
2
|
|
|
|
|
14
|
|
6
|
2
|
|
|
2
|
|
664
|
use App::TeleGramma::BotAction::Listen; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
7
|
2
|
|
|
2
|
|
54
|
use App::TeleGramma::Constants qw/:const/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
220
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12
|
use File::Spec::Functions qw/catfile/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
611
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $regex = qr/^thanks [,]? \s* (\w+)/xi; |
12
|
|
|
|
|
|
|
#$regex = qr/(a)/i; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub synopsis { |
15
|
0
|
|
|
0
|
1
|
0
|
"Gives the appropriate response to thanks" |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub default_config { |
19
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
20
|
1
|
|
|
|
|
4
|
return { }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub register { |
24
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
my $thanks_happens = App::TeleGramma::BotAction::Listen->new( |
26
|
|
|
|
|
|
|
command => $regex, |
27
|
0
|
|
|
0
|
|
|
response => sub { $self->thants(@_) } |
28
|
0
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return ($thanks_happens); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub thants { |
34
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
my $msg = shift; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my ($thankee) = ($msg->text =~ $regex); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $result = $thankee; |
40
|
0
|
|
|
|
|
|
while (length $result) { |
41
|
0
|
0
|
|
|
|
|
last if $result =~ /^[aeiou]/i; |
42
|
0
|
|
|
|
|
|
$result = substr $result, 1; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
return PLUGIN_DECLINED if ! length $result; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $thants = "Thanks $thankee, th". lc $result; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$self->reply_to($msg, $thants); |
50
|
0
|
|
|
|
|
|
return PLUGIN_RESPONDED; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=encoding UTF-8 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
App::TeleGramma::Plugin::Core::Thants - TeleGramma plugin to give thants where necessary |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 VERSION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
version 0.12 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Justin Hawkins <justin@eatmorecode.com> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Justin Hawkins <justin@eatmorecode.com>. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
78
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |