|
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\TelegramRawData; |
|
11
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\UpdatesArray; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* This will get the updates Telegram has for our bot |
|
15
|
|
|
* |
|
16
|
|
|
* This will work under 3 conditions: |
|
17
|
|
|
* |
|
18
|
|
|
* <ul> |
|
19
|
|
|
* <li>No more than 24 hours has passed since the last update</li> |
|
20
|
|
|
* <li>No webhooks are configured</li> |
|
21
|
|
|
* <li>There are available updates (doh)</li> |
|
22
|
|
|
* </ul> |
|
23
|
|
|
* |
|
24
|
|
|
* You can use this method to get the channel id the bot has to send messages to |
|
25
|
|
|
* |
|
26
|
|
|
* Objects defined as-is july 2016 |
|
27
|
|
|
* |
|
28
|
|
|
* @see https://core.telegram.org/bots/api#getupdates |
|
29
|
|
|
*/ |
|
30
|
|
|
class GetUpdates extends TelegramMethods |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of |
|
34
|
|
|
* previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An |
|
35
|
|
|
* update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. |
|
36
|
|
|
* @var int |
|
37
|
|
|
*/ |
|
38
|
|
|
public $offset = 0; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100 |
|
42
|
|
|
* @var int |
|
43
|
|
|
*/ |
|
44
|
|
|
public $limit = 100; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling |
|
48
|
|
|
* @var int |
|
49
|
|
|
*/ |
|
50
|
|
|
public $timeout = 0; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* This call will return an array with updates, so call up a custom type to do this |
|
54
|
|
|
* |
|
55
|
|
|
* @param array $data |
|
56
|
|
|
* @param LoggerInterface $logger |
|
57
|
|
|
* @return TelegramTypes |
|
58
|
|
|
*/ |
|
59
|
2 |
|
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes |
|
60
|
|
|
{ |
|
61
|
2 |
|
return new UpdatesArray($data->getResult(), $logger); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
3 |
|
public function getMandatoryFields(): array |
|
65
|
|
|
{ |
|
66
|
3 |
|
return []; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|