1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
6
|
|
|
|
7
|
|
|
use Generator; |
8
|
|
|
use unreal4u\TelegramAPI\Abstracts\KeyboardMethods; |
9
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
10
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. |
14
|
|
|
* For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or |
15
|
|
|
* Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, |
16
|
|
|
* this limit may be changed in the future. |
17
|
|
|
* |
18
|
|
|
* Objects defined as-is February 2018 |
19
|
|
|
* |
20
|
|
|
* @see https://core.telegram.org/bots/api#sendvoice |
21
|
|
|
*/ |
22
|
|
|
class SendVoice extends TelegramMethods |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
public $chat_id = ''; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), |
32
|
|
|
* pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using the |
33
|
|
|
* InputFile class |
34
|
|
|
* @see InputFile |
35
|
|
|
* @var string|InputFile |
36
|
|
|
*/ |
37
|
|
|
public $voice = ''; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Optional. Audio caption, 0-200 characters |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
public $caption = ''; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs |
47
|
|
|
* in the media caption |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
public $parse_mode = ''; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Optional. Duration of sent voice message in seconds |
54
|
|
|
* @var int |
55
|
|
|
*/ |
56
|
|
|
public $duration = 0; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Optional. Sends the message silently. iOS users will not receive a notification, Android users will receive a |
60
|
|
|
* notification with no sound. |
61
|
|
|
* @see https://telegram.org/blog/channels-2-0#silent-messages |
62
|
|
|
* @var bool |
63
|
|
|
*/ |
64
|
|
|
public $disable_notification = false; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Optional. If the message is a reply, ID of the original message |
68
|
|
|
* @var int |
69
|
|
|
*/ |
70
|
|
|
public $reply_to_message_id = 0; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to |
74
|
|
|
* hide keyboard or to force a reply from the user |
75
|
|
|
* @var KeyboardMethods |
76
|
|
|
*/ |
77
|
|
|
public $reply_markup; |
78
|
|
|
|
79
|
|
|
public function getMandatoryFields(): array |
80
|
|
|
{ |
81
|
|
|
return [ |
82
|
|
|
'chat_id', |
83
|
|
|
'voice', |
84
|
|
|
]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function hasLocalFiles(): bool |
88
|
|
|
{ |
89
|
|
|
return $this->voice instanceof InputFile; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getLocalFiles(): Generator |
93
|
|
|
{ |
94
|
|
|
yield 'voice' => $this->voice; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|