1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
6
|
|
|
|
7
|
|
|
use unreal4u\TelegramAPI\Abstracts\KeyboardMethods; |
8
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
9
|
|
|
use function json_encode; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Use this method to send point on the map. On success, the sent Message is returned. |
13
|
|
|
* |
14
|
|
|
* Objects defined as-is june 2019 |
15
|
|
|
* |
16
|
|
|
* @see https://core.telegram.org/bots/api#sendpoll |
17
|
|
|
*/ |
18
|
|
|
class SendPoll extends TelegramMethods |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Unique identifier for the target chat or username of the target channel (in the format @channelusername). A |
22
|
|
|
* native poll can't be sent to a private chat |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
public $chat_id = ''; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Poll question, 1-255 characters |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
public $question = ''; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* List of answer options, 2-10 strings 1-100 characters each |
35
|
|
|
* @var string[] |
36
|
|
|
*/ |
37
|
|
|
public $options = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Optional. Sends the message silently. iOS users will not receive a notification, Android users will receive a |
41
|
|
|
* notification with no sound. |
42
|
|
|
* @see https://telegram.org/blog/channels-2-0#silent-messages |
43
|
|
|
* @var bool |
44
|
|
|
*/ |
45
|
|
|
public $disable_notification = false; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* If the message is a reply, ID of the original message |
49
|
|
|
* @var int |
50
|
|
|
*/ |
51
|
|
|
public $reply_to_message_id = 0; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to |
55
|
|
|
* hide keyboard or to force a reply from the user. |
56
|
|
|
* @var KeyboardMethods |
57
|
|
|
*/ |
58
|
|
|
public $reply_markup; |
59
|
|
|
|
60
|
|
|
public function getMandatoryFields(): array |
61
|
|
|
{ |
62
|
|
|
return [ |
63
|
|
|
'chat_id', |
64
|
|
|
'question', |
65
|
|
|
'options', |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function performSpecialConditions(): TelegramMethods |
70
|
|
|
{ |
71
|
|
|
$this->options = json_encode($this->options); |
72
|
|
|
return parent::performSpecialConditions(); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|