1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Zanzara\Telegram\Type; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This object represents a chat. |
9
|
|
|
* |
10
|
|
|
* More on https://core.telegram.org/bots/api#chat |
11
|
|
|
*/ |
12
|
|
|
class Chat implements \JsonSerializable |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have |
17
|
|
|
* difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or |
18
|
|
|
* double-precision float type are safe for storing this identifier. |
19
|
|
|
* |
20
|
|
|
* @var int |
21
|
|
|
*/ |
22
|
|
|
private $id; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Type of chat, can be either "private", "group", "supergroup" or "channel" |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $type; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Optional. Title, for supergroups, channels and group chats |
33
|
|
|
* |
34
|
|
|
* @var string|null |
35
|
|
|
*/ |
36
|
|
|
private $title; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Optional. Username, for private chats, supergroups and channels if available |
40
|
|
|
* |
41
|
|
|
* @var string|null |
42
|
|
|
*/ |
43
|
|
|
private $username; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Optional. First name of the other party in a private chat |
47
|
|
|
* |
48
|
|
|
* @var string|null |
49
|
|
|
*/ |
50
|
|
|
private $first_name; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Optional. Last name of the other party in a private chat |
54
|
|
|
* |
55
|
|
|
* @var string|null |
56
|
|
|
*/ |
57
|
|
|
private $last_name; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Optional. Chat photo. Returned only in getChat. |
61
|
|
|
* |
62
|
|
|
* @var ChatPhoto|null |
63
|
|
|
*/ |
64
|
|
|
private $photo; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Optional. Bio of the other party in a private chat. Returned only in getChat. |
68
|
|
|
* |
69
|
|
|
* @since zanzara 0.5.0, Telegram Bot Api 5.0 |
70
|
|
|
* |
71
|
|
|
* @var string|null |
72
|
|
|
*/ |
73
|
|
|
private $bio; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. |
77
|
|
|
* |
78
|
|
|
* @var string|null |
79
|
|
|
*/ |
80
|
|
|
private $description; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Optional. Chat invite link, for groups, supergroups and channel chats. Each administrator in a chat generates their |
84
|
|
|
* own invite links, so the bot must first generate the link using exportChatInviteLink. Returned only in getChat. |
85
|
|
|
* |
86
|
|
|
* @var string|null |
87
|
|
|
*/ |
88
|
|
|
private $invite_link; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Optional. Pinned message, for groups, supergroups and channels. Returned only in getChat. |
92
|
|
|
* |
93
|
|
|
* @var Message|null |
94
|
|
|
*/ |
95
|
|
|
private $pinned_message; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. |
99
|
|
|
* |
100
|
|
|
* @var ChatPermissions|null |
101
|
|
|
*/ |
102
|
|
|
private $permissions; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. |
106
|
|
|
* Returned only in getChat. |
107
|
|
|
* |
108
|
|
|
* @var int|null |
109
|
|
|
*/ |
110
|
|
|
private $slow_mode_delay; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Optional. For supergroups, name of group sticker set. Returned only in getChat. |
114
|
|
|
* |
115
|
|
|
* @var string|null |
116
|
|
|
*/ |
117
|
|
|
private $sticker_set_name; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Optional. True, if the bot can change the group sticker set. Returned only in getChat. |
121
|
|
|
* |
122
|
|
|
* @var bool|null |
123
|
|
|
*/ |
124
|
|
|
private $can_set_sticker_set; |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice |
128
|
|
|
* versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming |
129
|
|
|
* languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 |
130
|
|
|
* bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. |
131
|
|
|
* |
132
|
|
|
* @since zanzara 0.5.0, Telegram Bot Api 5.0 |
133
|
|
|
* |
134
|
|
|
* @var int|null |
135
|
|
|
*/ |
136
|
|
|
private $linked_chat_id; |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. |
140
|
|
|
* |
141
|
|
|
* @since zanzara 0.5.0, Telegram Bot Api 5.0 |
142
|
|
|
* |
143
|
|
|
* @var ChatLocation|null |
144
|
|
|
*/ |
145
|
|
|
private $location; |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return int |
149
|
|
|
*/ |
150
|
|
|
public function getId(): int |
151
|
|
|
{ |
152
|
|
|
return $this->id; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param int $id |
157
|
|
|
*/ |
158
|
|
|
public function setId(int $id): void |
159
|
|
|
{ |
160
|
|
|
$this->id = $id; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
public function getType(): string |
167
|
|
|
{ |
168
|
|
|
return $this->type; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param string $type |
173
|
|
|
*/ |
174
|
|
|
public function setType(string $type): void |
175
|
|
|
{ |
176
|
|
|
$this->type = $type; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @return string|null |
181
|
|
|
*/ |
182
|
|
|
public function getTitle(): ?string |
183
|
|
|
{ |
184
|
|
|
return $this->title; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @param string|null $title |
189
|
|
|
*/ |
190
|
|
|
public function setTitle(?string $title): void |
191
|
|
|
{ |
192
|
|
|
$this->title = $title; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return string|null |
197
|
|
|
*/ |
198
|
|
|
public function getUsername(): ?string |
199
|
|
|
{ |
200
|
|
|
return $this->username; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @param string|null $username |
205
|
|
|
*/ |
206
|
|
|
public function setUsername(?string $username): void |
207
|
|
|
{ |
208
|
|
|
$this->username = $username; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @return string|null |
213
|
|
|
*/ |
214
|
|
|
public function getFirstName(): ?string |
215
|
|
|
{ |
216
|
|
|
return $this->first_name; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @param string|null $first_name |
221
|
|
|
*/ |
222
|
|
|
public function setFirstName(?string $first_name): void |
223
|
|
|
{ |
224
|
|
|
$this->first_name = $first_name; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @return string|null |
229
|
|
|
*/ |
230
|
|
|
public function getLastName(): ?string |
231
|
|
|
{ |
232
|
|
|
return $this->last_name; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @param string|null $last_name |
237
|
|
|
*/ |
238
|
|
|
public function setLastName(?string $last_name): void |
239
|
|
|
{ |
240
|
|
|
$this->last_name = $last_name; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @return ChatPhoto|null |
245
|
|
|
*/ |
246
|
|
|
public function getPhoto(): ?ChatPhoto |
247
|
|
|
{ |
248
|
|
|
return $this->photo; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @param ChatPhoto|null $photo |
253
|
|
|
*/ |
254
|
|
|
public function setPhoto(?ChatPhoto $photo): void |
255
|
|
|
{ |
256
|
|
|
$this->photo = $photo; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @return string|null |
261
|
|
|
*/ |
262
|
|
|
public function getDescription(): ?string |
263
|
|
|
{ |
264
|
|
|
return $this->description; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @param string|null $description |
269
|
|
|
*/ |
270
|
|
|
public function setDescription(?string $description): void |
271
|
|
|
{ |
272
|
|
|
$this->description = $description; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @return string|null |
277
|
|
|
*/ |
278
|
|
|
public function getInviteLink(): ?string |
279
|
|
|
{ |
280
|
|
|
return $this->invite_link; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @param string|null $invite_link |
285
|
|
|
*/ |
286
|
|
|
public function setInviteLink(?string $invite_link): void |
287
|
|
|
{ |
288
|
|
|
$this->invite_link = $invite_link; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* @return Message|null |
293
|
|
|
*/ |
294
|
|
|
public function getPinnedMessage(): ?Message |
295
|
|
|
{ |
296
|
|
|
return $this->pinned_message; |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* @param Message|null $pinned_message |
301
|
|
|
*/ |
302
|
|
|
public function setPinnedMessage(?Message $pinned_message): void |
303
|
|
|
{ |
304
|
|
|
$this->pinned_message = $pinned_message; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @return ChatPermissions|null |
309
|
|
|
*/ |
310
|
|
|
public function getPermissions(): ?ChatPermissions |
311
|
|
|
{ |
312
|
|
|
return $this->permissions; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @param ChatPermissions|null $permissions |
317
|
|
|
*/ |
318
|
|
|
public function setPermissions(?ChatPermissions $permissions): void |
319
|
|
|
{ |
320
|
|
|
$this->permissions = $permissions; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @return int|null |
325
|
|
|
*/ |
326
|
|
|
public function getSlowModeDelay(): ?int |
327
|
|
|
{ |
328
|
|
|
return $this->slow_mode_delay; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @param int|null $slow_mode_delay |
333
|
|
|
*/ |
334
|
|
|
public function setSlowModeDelay(?int $slow_mode_delay): void |
335
|
|
|
{ |
336
|
|
|
$this->slow_mode_delay = $slow_mode_delay; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @return string|null |
341
|
|
|
*/ |
342
|
|
|
public function getStickerSetName(): ?string |
343
|
|
|
{ |
344
|
|
|
return $this->sticker_set_name; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @param string|null $sticker_set_name |
349
|
|
|
*/ |
350
|
|
|
public function setStickerSetName(?string $sticker_set_name): void |
351
|
|
|
{ |
352
|
|
|
$this->sticker_set_name = $sticker_set_name; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @return bool|null |
357
|
|
|
*/ |
358
|
|
|
public function getCanSetStickerSet(): ?bool |
359
|
|
|
{ |
360
|
|
|
return $this->can_set_sticker_set; |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* @param bool|null $can_set_sticker_set |
365
|
|
|
*/ |
366
|
|
|
public function setCanSetStickerSet(?bool $can_set_sticker_set): void |
367
|
|
|
{ |
368
|
|
|
$this->can_set_sticker_set = $can_set_sticker_set; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
public function __toString() |
372
|
|
|
{ |
373
|
|
|
return json_encode($this, JSON_PRETTY_PRINT); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* @inheritDoc |
378
|
|
|
*/ |
379
|
|
|
public function jsonSerialize() |
380
|
|
|
{ |
381
|
|
|
return [ |
382
|
|
|
'id' => $this->id, |
383
|
|
|
'type' => $this->type, |
384
|
|
|
'username' => $this->username, |
385
|
|
|
'first_name' => $this->first_name, |
386
|
|
|
'last_name' => $this->last_name |
387
|
|
|
]; |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
/** |
391
|
|
|
* @return string|null |
392
|
|
|
*/ |
393
|
|
|
public function getBio(): ?string |
394
|
|
|
{ |
395
|
|
|
return $this->bio; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* @param string|null $bio |
400
|
|
|
*/ |
401
|
|
|
public function setBio(?string $bio): void |
402
|
|
|
{ |
403
|
|
|
$this->bio = $bio; |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* @return int|null |
408
|
|
|
*/ |
409
|
|
|
public function getLinkedChatId(): ?int |
410
|
|
|
{ |
411
|
|
|
return $this->linked_chat_id; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* @param int|null $linked_chat_id |
416
|
|
|
*/ |
417
|
|
|
public function setLinkedChatId(?int $linked_chat_id): void |
418
|
|
|
{ |
419
|
|
|
$this->linked_chat_id = $linked_chat_id; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* @return ChatLocation|null |
424
|
|
|
*/ |
425
|
|
|
public function getLocation(): ?ChatLocation |
426
|
|
|
{ |
427
|
|
|
return $this->location; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* @param ChatLocation|null $location |
432
|
|
|
*/ |
433
|
|
|
public function setLocation(?ChatLocation $location): void |
434
|
|
|
{ |
435
|
|
|
$this->location = $location; |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
} |