|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Method; |
|
6
|
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Exception\BadArgumentException; |
|
8
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface; |
|
9
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
|
10
|
|
|
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class SendDiceMethod. |
|
14
|
|
|
* |
|
15
|
|
|
* Use this method to send a dice, which will have a random value from 1 to 6. |
|
16
|
|
|
* On success, the sent Message is returned. |
|
17
|
|
|
* (Yes, we're aware of the βproperβ singular of die. |
|
18
|
|
|
* But it's awkward, and we decided to help it change. |
|
19
|
|
|
* One dice at a time!) |
|
20
|
|
|
* |
|
21
|
|
|
* @see https://core.telegram.org/bots/api#senddice |
|
22
|
|
|
*/ |
|
23
|
|
|
class SendDiceMethod implements SendMethodAliasInterface |
|
24
|
|
|
{ |
|
25
|
|
|
use SendToChatVariablesTrait; |
|
26
|
|
|
use FillFromArrayTrait; |
|
27
|
|
|
|
|
28
|
|
|
public const EMOJI_DICE = 'π²'; |
|
29
|
|
|
public const EMOJI_DARTS = 'π―'; |
|
30
|
|
|
public const EMOJI_BASKETBALL = 'π'; |
|
31
|
|
|
public const EMOJI_FOOTBALL = 'β½'; |
|
32
|
|
|
public const EMOJI_SLOT_MACHINE = 'π°'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Emoji on which the dice throw animation is based. |
|
36
|
|
|
* Currently, must be one of βπ²β, βπ―β, βπβ, ββ½β, or βπ°β. |
|
37
|
|
|
* Dice can have values 1-6 for βπ²β and βπ―β, values 1-5 for βπβ and ββ½β, |
|
38
|
|
|
* and values 1-64 for βπ°β. Defaults to βπ²β. |
|
39
|
|
|
* |
|
40
|
|
|
* @var string|null |
|
41
|
|
|
*/ |
|
42
|
|
|
public $emoji; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param int|string $chatId |
|
46
|
|
|
* |
|
47
|
|
|
* @throws BadArgumentException |
|
48
|
|
|
*/ |
|
49
|
1 |
|
public static function create($chatId, array $data = null): SendDiceMethod |
|
50
|
|
|
{ |
|
51
|
1 |
|
$instance = new static(); |
|
52
|
1 |
|
$instance->chatId = $chatId; |
|
53
|
|
|
|
|
54
|
1 |
|
if ($data) { |
|
55
|
1 |
|
$instance->fill($data); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
1 |
|
return $instance; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param $chatId |
|
63
|
|
|
* |
|
64
|
|
|
* @throws BadArgumentException |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public static function createWithDice($chatId, array $data = null): SendDiceMethod |
|
67
|
|
|
{ |
|
68
|
1 |
|
$instance = static::create($chatId, $data); |
|
69
|
1 |
|
$instance->emoji = static::EMOJI_DICE; |
|
70
|
|
|
|
|
71
|
1 |
|
return $instance; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param $chatId |
|
76
|
|
|
* |
|
77
|
|
|
* @throws BadArgumentException |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public static function createWithDarts($chatId, array $data = null): SendDiceMethod |
|
80
|
|
|
{ |
|
81
|
1 |
|
$instance = static::create($chatId, $data); |
|
82
|
1 |
|
$instance->emoji = self::EMOJI_DARTS; |
|
83
|
|
|
|
|
84
|
1 |
|
return $instance; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param $chatId |
|
89
|
|
|
* |
|
90
|
|
|
* @throws BadArgumentException |
|
91
|
|
|
*/ |
|
92
|
1 |
|
public static function createWithBasketball($chatId, array $data = null): SendDiceMethod |
|
93
|
|
|
{ |
|
94
|
1 |
|
$instance = static::create($chatId, $data); |
|
95
|
1 |
|
$instance->emoji = self::EMOJI_BASKETBALL; |
|
96
|
|
|
|
|
97
|
1 |
|
return $instance; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param $chatId |
|
102
|
|
|
* |
|
103
|
|
|
* @throws BadArgumentException |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public static function createWithFootBall($chatId, array $data = null): SendDiceMethod |
|
106
|
|
|
{ |
|
107
|
1 |
|
$instance = static::create($chatId, $data); |
|
108
|
1 |
|
$instance->emoji = self::EMOJI_FOOTBALL; |
|
109
|
|
|
|
|
110
|
1 |
|
return $instance; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param $chatId |
|
115
|
|
|
* |
|
116
|
|
|
* @throws BadArgumentException |
|
117
|
|
|
*/ |
|
118
|
1 |
|
public static function createWithSlotMachine($chatId, array $data = null): SendDiceMethod |
|
119
|
|
|
{ |
|
120
|
1 |
|
$instance = static::create($chatId, $data); |
|
121
|
1 |
|
$instance->emoji = self::EMOJI_SLOT_MACHINE; |
|
122
|
|
|
|
|
123
|
1 |
|
return $instance; |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|