1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: iGusev |
5
|
|
|
* Date: 14/04/16 |
6
|
|
|
* Time: 16:53 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace TelegramBot\Api\Types\Inline\QueryResult; |
10
|
|
|
|
11
|
|
|
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup; |
12
|
|
|
use TelegramBot\Api\Types\Inline\InputMessageContent; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Audio |
16
|
|
|
* |
17
|
|
|
* @see https://core.telegram.org/bots/api#inlinequeryresultaudio |
18
|
|
|
* Represents a link to an mp3 audio file. By default, this audio file will be sent by the user. |
19
|
|
|
* Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. |
20
|
|
|
* |
21
|
|
|
* Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them. |
22
|
|
|
* |
23
|
|
|
* @package TelegramBot\Api\Types\Inline\QueryResult |
24
|
|
|
*/ |
25
|
|
|
class Audio extends AbstractInlineQueryResult |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
* |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
static protected $requiredParams = ['type', 'id', 'audio_url', 'title']; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
* |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
static protected $map = [ |
40
|
|
|
'type' => true, |
41
|
|
|
'id' => true, |
42
|
|
|
'audio_url' => true, |
43
|
|
|
'title' => true, |
44
|
|
|
'performer' => true, |
45
|
|
|
'audio_duration' => true, |
46
|
|
|
'reply_markup' => InlineKeyboardMarkup::class, |
47
|
|
|
'input_message_content' => InputMessageContent::class, |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $type = 'audio'; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* A valid URL for the audio file |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
protected $audioUrl; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Optional. Performer |
66
|
|
|
* |
67
|
|
|
* @var string |
68
|
|
|
*/ |
69
|
|
|
protected $performer; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Optional. Audio duration in seconds |
73
|
|
|
* |
74
|
|
|
* @var int |
75
|
|
|
*/ |
76
|
|
|
protected $audioDuration; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Audio constructor. |
80
|
|
|
* |
81
|
|
|
* @param string $id |
82
|
|
|
* @param string $audioUrl |
83
|
|
|
* @param string $title |
84
|
|
|
* @param string|null $performer |
85
|
|
|
* @param int|null $audioDuration |
86
|
|
|
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup |
87
|
|
|
* @param InputMessageContent|null $inputMessageContent |
88
|
|
|
*/ |
89
|
|
|
public function __construct( |
90
|
|
|
$id, |
91
|
|
|
$audioUrl, |
92
|
|
|
$title, |
93
|
|
|
$performer = null, |
94
|
|
|
$audioDuration = null, |
95
|
|
|
$inlineKeyboardMarkup = null, |
96
|
|
|
$inputMessageContent = null |
97
|
|
|
) { |
98
|
|
|
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup); |
99
|
|
|
|
100
|
|
|
$this->audioUrl = $audioUrl; |
101
|
|
|
$this->performer = $performer; |
102
|
|
|
$this->audioDuration = $audioDuration; |
103
|
|
|
$this->replyMarkup = $inlineKeyboardMarkup; |
104
|
|
|
$this->inputMessageContent = $inputMessageContent; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
|
|
public function getAudioUrl() |
111
|
|
|
{ |
112
|
|
|
return $this->audioUrl; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param string $audioUrl |
117
|
|
|
*/ |
118
|
|
|
public function setAudioUrl($audioUrl) |
119
|
|
|
{ |
120
|
|
|
$this->audioUrl = $audioUrl; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getPerformer() |
127
|
|
|
{ |
128
|
|
|
return $this->performer; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $performer |
133
|
|
|
*/ |
134
|
|
|
public function setPerformer($performer) |
135
|
|
|
{ |
136
|
|
|
$this->performer = $performer; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return int |
141
|
|
|
*/ |
142
|
|
|
public function getAudioDuration() |
143
|
|
|
{ |
144
|
|
|
return $this->audioDuration; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param int $audioDuration |
149
|
|
|
*/ |
150
|
|
|
public function setAudioDuration($audioDuration) |
151
|
|
|
{ |
152
|
|
|
$this->audioDuration = $audioDuration; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|