File Coverage

blib/lib/Telegram/Bot/Object/Message.pm
Criterion Covered Total %
statement 86 91 94.5
branch n/a
condition 0 5 0.0
subroutine 30 31 96.7
pod 2 3 66.6
total 118 130 90.7


line stmt bran cond sub pod time code
1             package Telegram::Bot::Object::Message;
2             $Telegram::Bot::Object::Message::VERSION = '0.029';
3             # ABSTRACT: The base class for the Telegram type "Message".
4              
5              
6 5     5   957777 use Mojo::Base 'Telegram::Bot::Object::Base';
  5         37293  
  5         45  
7              
8 5     5   3196 use Telegram::Bot::Object::User;
  5         20  
  5         37  
9 5     5   2984 use Telegram::Bot::Object::Chat;
  5         17  
  5         37  
10 5     5   2957 use Telegram::Bot::Object::MessageEntity;
  5         18  
  5         37  
11 5     5   3271 use Telegram::Bot::Object::Audio;
  5         43  
  5         36  
12 5     5   2673 use Telegram::Bot::Object::Document;
  5         15  
  5         32  
13 5     5   2635 use Telegram::Bot::Object::Animation;
  5         26  
  5         49  
14 5     5   13494 use Telegram::Bot::Object::Game;
  5         15  
  5         32  
15 5     5   214 use Telegram::Bot::Object::PhotoSize;
  5         9  
  5         21  
16 5     5   2578 use Telegram::Bot::Object::Sticker;
  5         17  
  5         45  
17 5     5   2816 use Telegram::Bot::Object::Video;
  5         14  
  5         29  
18 5     5   2695 use Telegram::Bot::Object::Voice;
  5         15  
  5         31  
19 5     5   2726 use Telegram::Bot::Object::VideoNote;
  5         15  
  5         34  
20 5     5   2920 use Telegram::Bot::Object::Contact;
  5         15  
  5         31  
21 5     5   2576 use Telegram::Bot::Object::Location;
  5         17  
  5         32  
22 5     5   2751 use Telegram::Bot::Object::Poll;
  5         16  
  5         33  
23 5     5   278 use Telegram::Bot::Object::Location;
  5         13  
  5         30  
24 5     5   155 use Telegram::Bot::Object::PhotoSize;
  5         9  
  5         29  
25 5     5   2541 use Telegram::Bot::Object::Invoice;
  5         14  
  5         44  
26 5     5   2941 use Telegram::Bot::Object::Venue;
  5         81  
  5         36  
27 5     5   2624 use Telegram::Bot::Object::SuccessfulPayment;
  5         15  
  5         31  
28 5     5   2734 use Telegram::Bot::Object::PassportData;
  5         15  
  5         29  
29 5     5   2714 use Telegram::Bot::Object::InlineKeyboardMarkup;
  5         16  
  5         30  
30 5     5   2760 use Telegram::Bot::Object::ReplyKeyboardMarkup;
  5         15  
  5         32  
31 5     5   2693 use Telegram::Bot::Object::InlineQuery;
  5         20  
  5         64  
32 5     5   7102 use Telegram::Bot::Object::ForceReply;
  5         19  
  5         41  
33 5     5   3744 use Telegram::Bot::Object::ReplyParameters;
  5         17  
  5         36  
34              
35 5     5   263 use Data::Dumper;
  5         11  
  5         4244  
36              
37             # basic message stuff
38             has 'message_id';
39             has 'from'; # User
40             has 'date';
41             has 'chat'; # Chat
42              
43             has 'forward_from'; # User
44             has 'forward_from_chat'; # Chat
45             has 'sender_chat'; # Chat
46             has 'forward_from_message_id';
47             has 'forward_signature';
48             has 'forward_sender_name';
49             has 'forward_date';
50              
51             has 'reply_to_message'; # Message
52             has 'edit_date';
53             has 'media_group_id';
54             has 'author_signature';
55             has 'text';
56             has 'entities'; # Array of MessageEntity
57              
58             has 'caption_entities'; # Array of MessageEntity
59              
60             has 'audio'; # Audio
61             has 'document'; # Document
62             has 'animation'; # Animation
63             has 'game'; # Game
64             has 'photo'; # Array of PhotoSize
65             has 'sticker'; # Sticker
66             has 'video'; # Video
67             has 'voice'; # Voice
68             has 'video_note'; # VideoNote
69             has 'caption';
70             has 'contact'; # Contact
71             has 'location'; # Location
72             has 'venue'; # Venue
73             has 'poll'; # Poll
74             has 'new_chat_members'; # Array of User
75             has 'left_chat_member'; # User
76             has 'new_chat_title';
77             has 'new_chat_photo'; # Array of PhotoSize
78             has 'delete_chat_photo';
79             has 'group_chat_created';
80             has 'supergroup_chat_created';
81             has 'channel_chat_created';
82             has 'migrate_to_chat_id';
83             has 'migrate_from_chat_id';
84             has 'pinned_message'; # Message
85             has 'invoice'; # Invoice
86             has 'successful_payment'; # SuccessfulPayment
87             has 'connected_website';
88             has 'passport_data'; # PassportData
89             has 'reply_markup'; # Array of InlineKeyboardMarkup/ReplyKeyboardMarkup
90             has 'inline_query'; # InlineQuery
91             has 'reply_parameters';
92              
93             sub fields {
94             return {
95 216     216 0 5463 'scalar' => [qw/message_id date forward_from_message_id
96             forward_signature forward_sender_name
97             forward_date edit_date media_group_id
98             author_signature text caption
99             new_chat_title delete_chat_photo
100             group_chat_created supergroup_chat_created
101             channel_chat_created migrate_to_chat_id
102             migrate_from_chat_id connected_website/],
103             'Telegram::Bot::Object::User' => [qw/from forward_from new_chat_members left_chat_member /],
104              
105             'Telegram::Bot::Object::Chat' => [qw/chat forward_from_chat sender_chat/],
106             'Telegram::Bot::Object::Message' => [qw/reply_to_message pinned_message/],
107             'Telegram::Bot::Object::MessageEntity' => [qw/entities caption_entities /],
108              
109             'Telegram::Bot::Object::Audio' => [qw/audio/],
110             'Telegram::Bot::Object::Document' => [qw/document/],
111             'Telegram::Bot::Object::Animation' => [qw/animation/],
112             'Telegram::Bot::Object::Game' => [qw/game/],
113             'Telegram::Bot::Object::PhotoSize' => [qw/photo new_chat_photo/],
114             'Telegram::Bot::Object::Sticker' => [qw/sticker/],
115             'Telegram::Bot::Object::Video' => [qw/video/],
116             'Telegram::Bot::Object::Voice' => [qw/voice/],
117             'Telegram::Bot::Object::VideoNote' => [qw/video_note/],
118              
119             'Telegram::Bot::Object::Contact' => [qw/contact/],
120             'Telegram::Bot::Object::Location' => [qw/location/],
121             'Telegram::Bot::Object::Venue' => [qw/venue/],
122              
123             'Telegram::Bot::Object::Poll' => [qw/poll/],
124              
125             'Telegram::Bot::Object::Invoice' => [qw/invoice/],
126             'Telegram::Bot::Object::SuccessfulPayment' => [qw/successful_payment/],
127             'Telegram::Bot::Object::PassportData' => [qw/passport_data/],
128             'Telegram::Bot::Object::InlineKeyboardMarkup' => [qw/reply_markup/],
129             'Telegram::Bot::Object::ReplyKeyboardMarkup' => [qw/reply_markup/],
130             'Telegram::Bot::Object::InlineQuery' => [qw/inline_query/],
131             'Telegram::Bot::Object::ForceReply' => [qw/reply_markup/],
132             'Telegram::Bot::Object::ReplyParameters' => [qw/reply_parameters/],
133              
134             };
135             }
136              
137             sub arrays {
138 35     35 1 954 qw/photo entities caption_entities new_chat_members new_chat_photo/
139             }
140              
141              
142             sub reply {
143 0     0 1   my $self = shift;
144 0           my $text = shift;
145 0   0       my $args = shift // {};
146              
147 0   0       $args->{reply_parameters} ||= Telegram::Bot::Object::ReplyParameters->new({message_id => $self->message_id });
148 0           return $self->_brain->sendMessage({chat_id => $self->chat->id, text => $text, %$args });
149             }
150              
151             1;
152              
153             __END__