|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Type; |
|
6
|
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class MessageEntityType. |
|
11
|
|
|
* |
|
12
|
|
|
* @see https://core.telegram.org/bots/api#messageentity |
|
13
|
|
|
*/ |
|
14
|
|
|
class MessageEntityType |
|
15
|
|
|
{ |
|
16
|
|
|
use FillFromArrayTrait; |
|
17
|
|
|
|
|
18
|
|
|
public const TYPE_MENTION = 'mention'; |
|
19
|
|
|
public const TYPE_HASHTAG = 'hashtag'; |
|
20
|
|
|
public const TYPE_CASH_TAG = 'cashtag'; |
|
21
|
|
|
public const TYPE_BOT_COMMAND = 'bot_command'; |
|
22
|
|
|
public const TYPE_URL = 'url'; |
|
23
|
|
|
public const TYPE_EMAIL = 'email'; |
|
24
|
|
|
public const TYPE_PHONE_NUMBER = 'phone_number'; |
|
25
|
|
|
public const TYPE_BOLD = 'bold'; |
|
26
|
|
|
public const TYPE_ITALIC = 'italic'; |
|
27
|
|
|
public const TYPE_UNDERLINE = 'underline'; |
|
28
|
|
|
public const TYPE_STRIKETHROUGH = 'strikethrough'; |
|
29
|
|
|
public const TYPE_CODE = 'code'; |
|
30
|
|
|
public const TYPE_PRE = 'pre'; |
|
31
|
|
|
public const TYPE_TEXT_LINK = 'text_link'; |
|
32
|
|
|
public const TYPE_TEXT_MENTION = 'text_mention'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Type of the entity. Can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), |
|
36
|
|
|
* “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” ([email protected]), |
|
37
|
|
|
* “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), |
|
38
|
|
|
* “strikethrough” (strikethrough text), “code” (monowidth string), “pre” (monowidth block), |
|
39
|
|
|
* “text_link” (for clickable text URLs), “text_mention” (for users without usernames). |
|
40
|
|
|
* |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
public $type; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Offset in UTF-16 code units to the start of the entity. |
|
47
|
|
|
* |
|
48
|
|
|
* @var int |
|
49
|
|
|
*/ |
|
50
|
|
|
public $offset; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Length of the entity in UTF-16 code units. |
|
54
|
|
|
* |
|
55
|
|
|
* @var int |
|
56
|
|
|
*/ |
|
57
|
|
|
public $length; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Optional. For “text_link” only, url that will be opened after user taps on the text. |
|
61
|
|
|
* |
|
62
|
|
|
* @var string|null |
|
63
|
|
|
*/ |
|
64
|
|
|
public $url; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Optional. For “text_mention” only, the mentioned user. |
|
68
|
|
|
* |
|
69
|
|
|
* @var UserType|null |
|
70
|
|
|
*/ |
|
71
|
|
|
public $user; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Optional. For “pre” only, the programming language of the entity text. |
|
75
|
|
|
* |
|
76
|
|
|
* @var string|null |
|
77
|
|
|
*/ |
|
78
|
|
|
public $language; |
|
79
|
|
|
|
|
80
|
10 |
|
public static function create(string $type, int $offset, int $length, array $data = null): MessageEntityType |
|
81
|
|
|
{ |
|
82
|
10 |
|
$instance = new static(); |
|
83
|
10 |
|
$instance->type = $type; |
|
84
|
10 |
|
$instance->offset = $offset; |
|
85
|
10 |
|
$instance->length = $length; |
|
86
|
|
|
|
|
87
|
10 |
|
if (!empty($data)) { |
|
88
|
1 |
|
$instance->fill($data); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
10 |
|
return $instance; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|