line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
## Net/API/Telegram/File.pm |
4
|
|
|
|
|
|
|
## Version 0.1 |
5
|
|
|
|
|
|
|
## Copyright(c) 2019 Jacques Deguest |
6
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
7
|
|
|
|
|
|
|
## Created 2019/05/29 |
8
|
|
|
|
|
|
|
## Modified 2020/03/28 |
9
|
|
|
|
|
|
|
## All rights reserved. |
10
|
|
|
|
|
|
|
## |
11
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or modify it |
12
|
|
|
|
|
|
|
## under the same terms as Perl itself. |
13
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
package Net::API::Telegram::File; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
1
|
|
|
1
|
|
1050
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
18
|
1
|
|
|
1
|
|
6
|
use parent qw( Net::API::Telegram::Generic ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
19
|
1
|
|
|
1
|
|
200
|
our( $VERSION ) = '0.1'; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
|
sub download { return( shift->_download( @_ ) ); } |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
1
|
|
sub file_id { return( shift->_set_get_scalar( 'file_id', @_ ) ); } |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
|
sub file_path { return( shift->_set_get_scalar( 'file_path', @_ ) ); } |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
0
|
1
|
|
sub file_size { return( shift->_set_get_number( 'file_size', @_ ) ); } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding utf-8 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Net::API::Telegram::File - A file ready to be downloaded |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $msg = Net::API::Telegram::File->new( %data ) || |
43
|
|
|
|
|
|
|
die( Net::API::Telegram::File->error, "\n" ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L<Net::API::Telegram::File> is a Telegram Message Object as defined here L<https://core.telegram.org/bots/api#file> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This module has been automatically generated from Telegram API documentation by the script scripts/telegram-doc2perl-methods.pl. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=over 4 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item B<new>( {INIT HASH REF}, %PARAMETERS ) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
B<new>() will create a new object for the package, pass any argument it might receive |
58
|
|
|
|
|
|
|
to the special standard routine B<init> that I<must> exist. |
59
|
|
|
|
|
|
|
Then it returns what returns B<init>(). |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The valid parameters are as follow. Methods available here are also parameters to the B<new> method. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over 8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * I<verbose> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item * I<debug> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=back |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item B<download>( file_id, [ file extension ] ) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Given a file id like file_id, this will call the B<getFile>() method from the parent L<Net::API::Telegram> package and receive a L<Net::API::Telegram::File> object in return, which contains a file path valid for only one hour according to Telegram api here L<https://core.telegram.org/bots/api#getfile>. With this file path, this B<download> method will issue a http get request and retrieve the file and save it locally in a temproary file generated by L<File::Temp>. If an extension is provided, it will be appended to the temproary file name such as C<myfile.jpg> otherwise the extension will be gussed from the mime type returned by the Telegram http server, if any. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This method returns undef() on error and sets a L<Net::API::Telegram::Error> or, on success, returns a hash reference with the following properties: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 8 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item I<filepath> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The full path to the temporary file |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item I<mime> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
The mime type returned by the server. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item I<response> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The L<HTTP::Response> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item I<size> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The size in bytes of the file fetched |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
=item B<download>( ) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item B<file_id>( String ) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Identifier for this file |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item B<file_path>( String ) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item B<file_size>( Integer ) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Optional. File size, if known |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=back |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copyright (c) 2000-2019 DEGUEST Pte. Ltd. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<Net::API::Telegram> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright (c) 2018-2019 DEGUEST Pte. Ltd. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
131
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|