BotKit/UpdateParser.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 30 CC 3 SCAR 18.4
CC
3
Cov
0%
_parse
12.0
get_text
2.0
get_chat_id
2.0
CRAP 6.3
1 package Telegram::BotKit::UpdateParser;
2 $Telegram::BotKit::UpdateParser::VERSION = '0.03';
3 # ABSTRACT: Module for parsing Telegram Update object. Resolve issue of getting text from inline or regular keyboard
4  
5  
6  
7 use common::sense;
8  
9 use Exporter qw(import);
10 our @EXPORT_OK = qw(get_chat_id get_text);
11  
12  
13 sub _parse {
14 my $update = shift;
15 if ($update->{message}{text}) {
16 return { data => $update->{message}{text}, chat_id => $update->{message}{chat}{id} };
17 }
18 if ($update->{callback_query}{data}) {
19 return { data => $update->{callback_query}{data}, chat_id => $update->{callback_query}{message}{chat}{id} };
20 }
21 }
22  
23  
24 sub get_text {
25 my $update = shift;
26 _parse($update)->{data};
27 }
28  
29  
30  
31 sub get_chat_id {
32 my $update = shift;
33 _parse($update)->{chat_id};
34 }
35  
36 1;
37  
38 __END__