|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Greenplugin\TelegramBot\Method; |
|
6
|
|
|
|
|
7
|
|
|
use Greenplugin\TelegramBot\Method\Interfaces\HasUpdateTypeVariableInterface; |
|
8
|
|
|
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait; |
|
9
|
|
|
use Greenplugin\TelegramBot\Type\InputFileType; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class SetWebhookMethod. |
|
13
|
|
|
* |
|
14
|
|
|
* @see https://core.telegram.org/bots/api#setwebhook |
|
15
|
|
|
* @see https://core.telegram.org/bots/webhooks |
|
16
|
|
|
*/ |
|
17
|
|
|
class SetWebhookMethod implements HasUpdateTypeVariableInterface |
|
18
|
|
|
{ |
|
19
|
|
|
use FillFromArrayTrait; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* HTTPS url to send updates to. Use an empty string to remove webhook integration. |
|
23
|
|
|
* |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
public $url; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Optional. Upload your public key certificate so that the root certificate in use can be checked. |
|
30
|
|
|
* |
|
31
|
|
|
* @see https://core.telegram.org/bots/self-signed |
|
32
|
|
|
* |
|
33
|
|
|
* @var InputFileType|null |
|
34
|
|
|
*/ |
|
35
|
|
|
public $certificate; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Optional Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. |
|
39
|
|
|
* Defaults to 40. Use lower values to limit the load on your bot‘s server, |
|
40
|
|
|
* and higher values to increase your bot’s throughput. |
|
41
|
|
|
* |
|
42
|
|
|
* @var int|null |
|
43
|
|
|
*/ |
|
44
|
|
|
public $maxConnections; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Optional List the types of updates you want your bot to receive. |
|
48
|
|
|
* For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. |
|
49
|
|
|
* See Update for a complete list of available update types. |
|
50
|
|
|
* Specify an empty list to receive all updates regardless of type (default). |
|
51
|
|
|
* If not specified, the previous setting will be used. |
|
52
|
|
|
* |
|
53
|
|
|
* Please note that this parameter doesn't affect updates created before the call to the setWebhook, |
|
54
|
|
|
* so unwanted updates may be received for a short period of time. |
|
55
|
|
|
* |
|
56
|
|
|
* @var string[]|null |
|
57
|
|
|
*/ |
|
58
|
|
|
public $allowedUpdates; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param string $url |
|
62
|
|
|
* @param array|null $data |
|
63
|
|
|
* |
|
64
|
|
|
* @throws \Greenplugin\TelegramBot\Exception\BadArgumentException |
|
65
|
|
|
* |
|
66
|
|
|
* @return SetWebhookMethod |
|
67
|
|
|
*/ |
|
68
|
|
|
public static function create(string $url, array $data = null): SetWebhookMethod |
|
69
|
|
|
{ |
|
70
|
|
|
$instance = new static(); |
|
71
|
|
|
$instance->$url; |
|
72
|
|
|
if ($data) { |
|
73
|
|
|
$instance->fill($data); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return $instance; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|