1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Method; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\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 \TgBotApi\BotApiBase\Exception\BadArgumentException |
76
|
|
|
* |
77
|
|
|
* @return SetGameScoreMethod |
78
|
|
|
*/ |
79
|
1 |
|
public static function create( |
80
|
|
|
int $userId, |
81
|
|
|
int $score, |
82
|
|
|
int $chatId, |
83
|
|
|
int $messageId, |
84
|
|
|
array $data = null |
85
|
|
|
): SetGameScoreMethod { |
86
|
1 |
|
$instance = new static(); |
87
|
1 |
|
$instance->userId = $userId; |
88
|
1 |
|
$instance->score = $score; |
89
|
1 |
|
$instance->chatId = $chatId; |
90
|
1 |
|
$instance->messageId = $messageId; |
91
|
1 |
|
if ($data) { |
92
|
1 |
|
$instance->fill($data); |
93
|
|
|
} |
94
|
|
|
|
95
|
1 |
|
return $instance; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param int $userId |
100
|
|
|
* @param int $score |
101
|
|
|
* @param string $inlineMessageId |
102
|
|
|
* @param array|null $data |
103
|
|
|
* |
104
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
105
|
|
|
* |
106
|
|
|
* @return SetGameScoreMethod |
107
|
|
|
*/ |
108
|
1 |
|
public static function createInline( |
109
|
|
|
int $userId, |
110
|
|
|
int $score, |
111
|
|
|
string $inlineMessageId, |
112
|
|
|
array $data = null |
113
|
|
|
): SetGameScoreMethod { |
114
|
1 |
|
$instance = new static(); |
115
|
1 |
|
$instance->userId = $userId; |
116
|
1 |
|
$instance->score = $score; |
117
|
1 |
|
$instance->inlineMessageId = $inlineMessageId; |
118
|
1 |
|
if ($data) { |
119
|
1 |
|
$instance->fill($data); |
120
|
|
|
} |
121
|
|
|
|
122
|
1 |
|
return $instance; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|