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