Skip to content

Commit 7a53421

Browse files
authored
Merge pull request #385 from bernard-ng/master
add support for forum topic (Bot API 6.3)
2 parents 0319825 + 2fa179f commit 7a53421

33 files changed

Lines changed: 2546 additions & 165 deletions

src/BotApi.php

Lines changed: 628 additions & 153 deletions
Large diffs are not rendered by default.

src/Types/Animation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Animation extends BaseType implements TypeInterface
1919
*
2020
* @var array
2121
*/
22-
static protected $requiredParams = ['file_id', 'width', 'height', 'duration'];
22+
static protected $requiredParams = ['file_id', 'file_unique_id', 'width', 'height', 'duration'];
2323

2424
/**
2525
* {@inheritdoc}
@@ -28,6 +28,7 @@ class Animation extends BaseType implements TypeInterface
2828
*/
2929
static protected $map = [
3030
'file_id' => true,
31+
'file_unique_id' => true,
3132
'width' => true,
3233
'height' => true,
3334
'duration' => true,

src/Types/ArrayOfSticker.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace TelegramBot\Api\Types;
4+
5+
abstract class ArrayOfSticker
6+
{
7+
public static function fromResponse($data)
8+
{
9+
$arrayOfStickers = [];
10+
foreach ($data as $sticker) {
11+
$arrayOfStickers[] = Sticker::fromResponse($sticker);
12+
}
13+
14+
return $arrayOfStickers;
15+
}
16+
}

src/Types/Audio.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Audio extends BaseType implements TypeInterface
1919
*
2020
* @var array
2121
*/
22-
static protected $requiredParams = ['file_id', 'duration'];
22+
static protected $requiredParams = ['file_id', 'file_unique_id', 'duration'];
2323

2424
/**
2525
* {@inheritdoc}
@@ -28,6 +28,7 @@ class Audio extends BaseType implements TypeInterface
2828
*/
2929
static protected $map = [
3030
'file_id' => true,
31+
'file_unique_id' => true,
3132
'duration' => true,
3233
'performer' => true,
3334
'title' => true,
@@ -77,6 +78,13 @@ class Audio extends BaseType implements TypeInterface
7778
*/
7879
protected $fileSize;
7980

81+
/**
82+
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
83+
*
84+
* @var string
85+
*/
86+
protected $fileUniqueId;
87+
8088
/**
8189
* @return int
8290
*/
@@ -184,4 +192,20 @@ public function setMimeType($mimeType)
184192
{
185193
$this->mimeType = $mimeType;
186194
}
195+
196+
/**
197+
* @return string
198+
*/
199+
public function getFileUniqueId()
200+
{
201+
return $this->fileUniqueId;
202+
}
203+
204+
/**
205+
* @param string $fileUniqueId
206+
*/
207+
public function setFileUniqueId($fileUniqueId)
208+
{
209+
$this->fileUniqueId = $fileUniqueId;
210+
}
187211
}

src/Types/Chat.php

Lines changed: 223 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ class Chat extends BaseType implements TypeInterface
3737
'sticker_set_name' => true,
3838
'can_set_sticker_set' => true,
3939
'linked_chat_id' => true,
40-
'location' => ChatLocation::class
40+
'location' => ChatLocation::class,
41+
'join_to_send_messages' => true,
42+
'join_by_request' => true,
43+
'message_auto_delete_time' => true,
44+
'has_protected_content' => true,
45+
'is_forum' => true,
46+
'active_usernames' => true,
47+
'emoji_status_custom_emoji_id' => true,
48+
'has_private_forwards' => true,
49+
'has_restricted_voice_and_video_messages' => true,
4150
];
4251

4352
/**
@@ -163,6 +172,74 @@ class Chat extends BaseType implements TypeInterface
163172
*/
164173
protected $location;
165174

175+
/**
176+
* Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat.
177+
*
178+
* @var bool
179+
*/
180+
protected $joinToSendMessages;
181+
182+
/**
183+
* Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat.
184+
*
185+
* @var bool
186+
*/
187+
protected $joinByRequest;
188+
189+
/**
190+
* Optional. Time after which all messages sent to the chat will be automatically deleted; in seconds. Returned
191+
* only in getChat.
192+
*
193+
* @var int
194+
*/
195+
protected $messageAutoDeleteTime;
196+
197+
/**
198+
* Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat.
199+
*
200+
* @var bool
201+
*/
202+
protected $hasProtectedContent;
203+
204+
/**
205+
* Optional. True, if the supergroup chat is a forum (has topics enabled)
206+
*
207+
* @var bool
208+
*/
209+
protected $isForum;
210+
211+
/**
212+
* Optional. If non-empty, the list of all active chat usernames;
213+
* for private chats, supergroups and channels. Returned only in getChat.
214+
*
215+
* @var array[]
216+
*/
217+
protected $activeUsernames;
218+
219+
/**
220+
* Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.
221+
*
222+
* @var string
223+
*/
224+
protected $emojiStatusCustomEmojiId;
225+
226+
/**
227+
* Optional. True, if privacy settings of the other party in the private chat allows
228+
* to use tg://user?id=<user_id> links only in chats with the user.
229+
* Returned only in getChat.
230+
*
231+
* @var bool
232+
*/
233+
protected $hasPrivateForwards;
234+
235+
/**
236+
* Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat.
237+
* Returned only in getChat.
238+
*
239+
* @var bool
240+
*/
241+
protected $hasRestrictedVoiceAndVideoMessages;
242+
166243
/**
167244
* @return int|string
168245
*/
@@ -396,7 +473,7 @@ public function setStickerSetName($stickerSetName)
396473
/**
397474
* @return bool
398475
*/
399-
public function isCanSetStickerSet()
476+
public function getCanSetStickerSet()
400477
{
401478
return $this->canSetStickerSet;
402479
}
@@ -440,4 +517,148 @@ public function setLocation($location)
440517
{
441518
$this->location = $location;
442519
}
520+
521+
/**
522+
* @return bool
523+
*/
524+
public function getJoinToSendMessages()
525+
{
526+
return $this->joinToSendMessages;
527+
}
528+
529+
/**
530+
* @param bool $joinToSendMessages
531+
*/
532+
public function setJoinToSendMessages($joinToSendMessages)
533+
{
534+
$this->joinToSendMessages = $joinToSendMessages;
535+
}
536+
537+
/**
538+
* @return bool
539+
*/
540+
public function getJoinByRequest()
541+
{
542+
return $this->joinByRequest;
543+
}
544+
545+
/**
546+
* @param bool $joinByRequest
547+
*/
548+
public function setJoinByRequest($joinByRequest)
549+
{
550+
$this->joinByRequest = $joinByRequest;
551+
}
552+
553+
/**
554+
* @return int
555+
*/
556+
public function getMessageAutoDeleteTime()
557+
{
558+
return $this->messageAutoDeleteTime;
559+
}
560+
561+
/**
562+
* @param int $messageAutoDeleteTime
563+
*/
564+
public function setMessageAutoDeleteTime($messageAutoDeleteTime)
565+
{
566+
$this->messageAutoDeleteTime = $messageAutoDeleteTime;
567+
}
568+
569+
/**
570+
* @return bool
571+
*/
572+
public function getHasProtectedContent()
573+
{
574+
return $this->hasProtectedContent;
575+
}
576+
577+
/**
578+
* @param bool $hasProtectedContent
579+
*/
580+
public function setHasProtectedContent($hasProtectedContent)
581+
{
582+
$this->hasProtectedContent = $hasProtectedContent;
583+
}
584+
585+
/**
586+
* @return bool
587+
*/
588+
public function getIsForum()
589+
{
590+
return $this->isForum;
591+
}
592+
593+
/**
594+
* @param bool $isForum
595+
*/
596+
public function setIsForum($isForum)
597+
{
598+
$this->isForum = $isForum;
599+
}
600+
601+
/**
602+
* @return array
603+
*/
604+
public function getActiveUsernames()
605+
{
606+
return $this->activeUsernames;
607+
}
608+
609+
/**
610+
* @param array $activeUsernames
611+
*/
612+
public function setActiveUsernames($activeUsernames)
613+
{
614+
$this->activeUsernames = $activeUsernames;
615+
}
616+
617+
/**
618+
* @return bool
619+
*/
620+
public function getEmojiStatusCustomEmojiId()
621+
{
622+
return $this->emojiStatusCustomEmojiId;
623+
}
624+
625+
/**
626+
* @param bool $emojiStatusCustomEmojiId
627+
*/
628+
public function setEmojiStatusCustomEmojiId($emojiStatusCustomEmojiId)
629+
{
630+
$this->emojiStatusCustomEmojiId = $emojiStatusCustomEmojiId;
631+
}
632+
633+
/**
634+
* @return bool
635+
*/
636+
public function getHasPrivateForwards()
637+
{
638+
return $this->hasPrivateForwards;
639+
}
640+
641+
/**
642+
* @param bool $hasPrivateForwards
643+
*/
644+
public function setHasPrivateForwards($hasPrivateForwards)
645+
{
646+
$this->hasPrivateForwards = $hasPrivateForwards;
647+
}
648+
649+
/**
650+
* @return bool
651+
*/
652+
public function getHasRestrictedVoiceAndVideoMessages()
653+
{
654+
return $this->hasRestrictedVoiceAndVideoMessages;
655+
}
656+
657+
/**
658+
* @param bool $hasRestrictedVoiceAndVideoMessages
659+
*/
660+
public function setHasRestrictedVoiceAndVideoMessages($hasRestrictedVoiceAndVideoMessages)
661+
{
662+
$this->hasRestrictedVoiceAndVideoMessages = $hasRestrictedVoiceAndVideoMessages;
663+
}
443664
}

0 commit comments

Comments
 (0)