1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
6
|
|
|
|
7
|
|
|
use Psr\Log\LoggerInterface; |
8
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
9
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; |
10
|
|
|
use unreal4u\TelegramAPI\InternalFunctionality\TelegramResponse; |
11
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\UpdatesArray; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned |
15
|
|
|
* |
16
|
|
|
* Objects defined as-is January 2017 |
17
|
|
|
* |
18
|
|
|
* @see https://core.telegram.org/bots/api#getupdates |
19
|
|
|
*/ |
20
|
|
|
class GetUpdates extends TelegramMethods |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of |
24
|
|
|
* previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An |
25
|
|
|
* update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The |
26
|
|
|
* negative offset can be specified to retrieve updates starting from -offset update from the end of the updates |
27
|
|
|
* queue. All previous updates will forgotten |
28
|
|
|
* @var int |
29
|
|
|
*/ |
30
|
|
|
public $offset = 0; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100 |
34
|
|
|
* @var int |
35
|
|
|
*/ |
36
|
|
|
public $limit = 100; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling |
40
|
|
|
* @var int |
41
|
|
|
*/ |
42
|
|
|
public $timeout = 0; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* List the types of updates you want your bot to receive. For example, specify |
46
|
|
|
* [“message”, “edited_channel_post”, “callback_query”] |
47
|
|
|
* to only receive updates of these types. See Update for a complete list of available update types. Specify an |
48
|
|
|
* empty list to receive all updates regardless of type (default). If not specified, the previous setting will be |
49
|
|
|
* used. |
50
|
|
|
* |
51
|
|
|
* Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted |
52
|
|
|
* updates may be received for a short period of time. |
53
|
|
|
* @see Update |
54
|
|
|
* @var string[] |
55
|
|
|
*/ |
56
|
|
|
public $allowed_updates = []; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* This call will return an array with updates, so call up a custom type to do this |
60
|
|
|
* |
61
|
|
|
* @param TelegramResponse $data |
62
|
|
|
* @param LoggerInterface $logger |
63
|
|
|
* @return TelegramTypes |
64
|
|
|
*/ |
65
|
5 |
|
public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes |
66
|
|
|
{ |
67
|
5 |
|
return new UpdatesArray($data->getResult(), $logger); |
68
|
|
|
} |
69
|
|
|
|
70
|
6 |
|
public function getMandatoryFields(): array |
71
|
|
|
{ |
72
|
6 |
|
return []; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|