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 them in the music player. Your audio |
14
|
|
|
* must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to |
15
|
|
|
* 50 MB in size, this limit may be changed in the future. |
16
|
|
|
* |
17
|
|
|
* For backward compatibility, when the fields title and performer are both empty and the mime-type of the file to be |
18
|
|
|
* sent is not audio/mpeg, the file will be sent as a playable voice message. For this to work, the audio must be in an |
19
|
|
|
* .ogg file encoded with OPUS. This behavior will be phased out in the future. For sending voice messages, use the |
20
|
|
|
* sendVoice method instead. |
21
|
|
|
* |
22
|
|
|
* Objects defined as-is February 2018 |
23
|
|
|
* |
24
|
|
|
* @see https://core.telegram.org/bots/api#sendaudio |
25
|
|
|
*/ |
26
|
|
|
class SendAudio extends TelegramMethods |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public $chat_id = ''; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers |
36
|
|
|
* (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new |
37
|
|
|
* one using the InputFile class |
38
|
|
|
* |
39
|
|
|
* @see InputFile |
40
|
|
|
* @var string|InputFile |
41
|
|
|
*/ |
42
|
|
|
public $audio = ''; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Optional. Audio caption, 0-200 characters |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
public $caption = ''; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs |
52
|
|
|
* in the media caption |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
public $parse_mode = ''; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Optional. Duration of the audio in seconds |
59
|
|
|
* @var int |
60
|
|
|
*/ |
61
|
|
|
public $duration = 0; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Optional. Performer |
65
|
|
|
* @var string |
66
|
|
|
*/ |
67
|
|
|
public $performer = ''; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Optional. Track name |
71
|
|
|
* @var string |
72
|
|
|
*/ |
73
|
|
|
public $title = ''; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Optional. Sends the message silently. iOS users will not receive a notification, Android users will receive a |
77
|
|
|
* notification with no sound. |
78
|
|
|
* @see https://telegram.org/blog/channels-2-0#silent-messages |
79
|
|
|
* @var bool |
80
|
|
|
*/ |
81
|
|
|
public $disable_notification = false; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Optional. If the message is a reply, ID of the original message |
85
|
|
|
* @var int |
86
|
|
|
*/ |
87
|
|
|
public $reply_to_message_id = 0; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to |
91
|
|
|
* hide keyboard or to force a reply from the user |
92
|
|
|
* @var KeyboardMethods |
93
|
|
|
*/ |
94
|
|
|
public $reply_markup; |
95
|
|
|
|
96
|
4 |
|
public function getMandatoryFields(): array |
97
|
|
|
{ |
98
|
|
|
return [ |
99
|
4 |
|
'chat_id', |
100
|
|
|
'audio', |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
|
104
|
1 |
|
public function hasLocalFiles(): bool |
105
|
|
|
{ |
106
|
1 |
|
return $this->audio instanceof InputFile; |
107
|
|
|
} |
108
|
|
|
|
109
|
1 |
|
public function getLocalFiles(): Generator |
110
|
|
|
{ |
111
|
1 |
|
yield 'audio' => $this->audio; |
112
|
1 |
|
} |
113
|
|
|
} |
114
|
|
|
|