|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Greenplugin\TelegramBot\Method; |
|
6
|
|
|
|
|
7
|
|
|
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class SetGameScoreMetod. |
|
11
|
|
|
* |
|
12
|
|
|
* @see https://core.telegram.org/bots/api#setgamescore |
|
13
|
|
|
*/ |
|
14
|
|
|
class SetGameScoreMethod |
|
15
|
|
|
{ |
|
16
|
|
|
use FillFromArrayTrait; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* User identifier. |
|
20
|
|
|
* |
|
21
|
|
|
* @var int |
|
22
|
|
|
*/ |
|
23
|
|
|
public $userId; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* New score, must be non-negative. |
|
27
|
|
|
* |
|
28
|
|
|
* @var int |
|
29
|
|
|
*/ |
|
30
|
|
|
public $score; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Optional. Pass True, if the high score is allowed to decrease. |
|
34
|
|
|
* This can be useful when fixing mistakes or banning cheaters. |
|
35
|
|
|
* |
|
36
|
|
|
* @var bool|null |
|
37
|
|
|
*/ |
|
38
|
|
|
public $force; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Optional. Pass True, if the game message should not be automatically edited to include the current scoreboard. |
|
42
|
|
|
* |
|
43
|
|
|
* @var bool|null |
|
44
|
|
|
*/ |
|
45
|
|
|
public $disableEditMessage; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Optional. Required if inline_message_id is not specified. Identifier of the sent message. |
|
49
|
|
|
* |
|
50
|
|
|
* @var int|null |
|
51
|
|
|
*/ |
|
52
|
|
|
public $chatId; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Optional. Required if inline_message_id is not specified. Identifier of the sent message. |
|
56
|
|
|
* |
|
57
|
|
|
* @var int|null |
|
58
|
|
|
*/ |
|
59
|
|
|
public $messageId; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Optional. Required if chat_id and message_id are not specified. Identifier of the inline message. |
|
63
|
|
|
* |
|
64
|
|
|
* @var string|null |
|
65
|
|
|
*/ |
|
66
|
|
|
public $inlineMessageId; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param int $userId |
|
70
|
|
|
* @param int $score |
|
71
|
|
|
* @param int $chatId |
|
72
|
|
|
* @param int $messageId |
|
73
|
|
|
* @param array|null $data |
|
74
|
|
|
* |
|
75
|
|
|
* @throws \Greenplugin\TelegramBot\Exception\BadArgumentException |
|
76
|
|
|
*/ |
|
77
|
|
|
public static function create(int $userId, int $score, int $chatId, int $messageId, array $data = null) |
|
78
|
|
|
{ |
|
79
|
|
|
$instance = new self(); |
|
80
|
|
|
$instance->userId = $userId; |
|
81
|
|
|
$instance->score = $score; |
|
82
|
|
|
$instance->chatId = $chatId; |
|
83
|
|
|
$instance->messageId = $messageId; |
|
84
|
|
|
if ($data) { |
|
85
|
|
|
$instance->fill($data); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param int $userId |
|
91
|
|
|
* @param int $score |
|
92
|
|
|
* @param string $inlineMessageId |
|
93
|
|
|
* @param array|null $data |
|
94
|
|
|
* |
|
95
|
|
|
* @throws \Greenplugin\TelegramBot\Exception\BadArgumentException |
|
96
|
|
|
*/ |
|
97
|
|
|
public static function createInline(int $userId, int $score, string $inlineMessageId, array $data = null) |
|
98
|
|
|
{ |
|
99
|
|
|
$instance = new self(); |
|
100
|
|
|
$instance->userId = $userId; |
|
101
|
|
|
$instance->score = $score; |
|
102
|
|
|
$instance->inlineMessageId = $inlineMessageId; |
|
103
|
|
|
if ($data) { |
|
104
|
|
|
$instance->fill($data); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|