line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
## Telegram API - ~/lib/Net/API/Telegram/Voice.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 2019/11/01 |
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::Voice; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
1
|
|
|
1
|
|
1151
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
18
|
1
|
|
|
1
|
|
5
|
use parent qw( Net::API::Telegram::Generic ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
19
|
1
|
|
|
1
|
|
247
|
our( $VERSION ) = '0.1'; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
|
sub download { return( shift->_download( @_ ) ); } |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
1
|
|
sub duration { return( shift->_set_get_number( 'duration', @_ ) ); } |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
|
sub file_id { return( shift->_set_get_scalar( 'file_id', @_ ) ); } |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
0
|
1
|
|
sub file_size { return( shift->_set_get_number( 'file_size', @_ ) ); } |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
|
sub mime_type { return( shift->_set_get_scalar( 'mime_type', @_ ) ); } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=encoding utf-8 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Net::API::Telegram::Voice - A voice note |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $msg = Net::API::Telegram::Voice->new( %data ) || |
45
|
|
|
|
|
|
|
die( Net::API::Telegram::Voice->error, "\n" ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L<Net::API::Telegram::Voice> is a Telegram Message Object as defined here L<https://core.telegram.org/bots/api#voice> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This module has been automatically generated from Telegram API documentation by the script scripts/telegram-doc2perl-methods.pl. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 METHODS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item B<new>( {INIT HASH REF}, %PARAMETERS ) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
B<new>() will create a new object for the package, pass any argument it might receive |
60
|
|
|
|
|
|
|
to the special standard routine B<init> that I<must> exist. |
61
|
|
|
|
|
|
|
Then it returns what returns B<init>(). |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The valid parameters are as follow. Methods available here are also parameters to the B<new> method. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over 8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item * I<verbose> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * I<debug> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=back |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item B<download>( file_id, [ file extension ] ) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
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. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
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: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 8 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item I<filepath> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The full path to the temporary file |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item I<mime> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The mime type returned by the server. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item I<response> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The L<HTTP::Response> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item I<size> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
The size in bytes of the file fetched |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
=item B<download>( ) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item B<duration>( Integer ) |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Duration of the audio in seconds as defined by sender |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item B<file_id>( String ) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Identifier for this file |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item B<file_size>( Integer ) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Optional. File size |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item B<mime_type>( String ) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Optional. MIME type of the file as defined by sender |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Copyright (c) 2000-2019 DEGUEST Pte. Ltd. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SEE ALSO |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<Net::API::Telegram> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright (c) 2018-2019 DEGUEST Pte. Ltd. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
137
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|