Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for forum topic (Bot API 6.3) #385

Merged
merged 10 commits into from
Mar 6, 2023
781 changes: 628 additions & 153 deletions src/BotApi.php

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/Types/Animation.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Animation extends BaseType implements TypeInterface
*
* @var array
*/
static protected $requiredParams = ['file_id', 'width', 'height', 'duration'];
static protected $requiredParams = ['file_id', 'file_unique_id', 'width', 'height', 'duration'];

/**
* {@inheritdoc}
Expand All @@ -28,6 +28,7 @@ class Animation extends BaseType implements TypeInterface
*/
static protected $map = [
'file_id' => true,
'file_unique_id' => true,
'width' => true,
'height' => true,
'duration' => true,
Expand Down
16 changes: 16 additions & 0 deletions src/Types/ArrayOfSticker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace TelegramBot\Api\Types;

abstract class ArrayOfSticker
{
public static function fromResponse($data)
{
$arrayOfStickers = [];
foreach ($data as $sticker) {
$arrayOfStickers[] = Sticker::fromResponse($sticker);
}

return $arrayOfStickers;
}
}
26 changes: 25 additions & 1 deletion src/Types/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Audio extends BaseType implements TypeInterface
*
* @var array
*/
static protected $requiredParams = ['file_id', 'duration'];
static protected $requiredParams = ['file_id', 'file_unique_id', 'duration'];

/**
* {@inheritdoc}
Expand All @@ -28,6 +28,7 @@ class Audio extends BaseType implements TypeInterface
*/
static protected $map = [
'file_id' => true,
'file_unique_id' => true,
'duration' => true,
'performer' => true,
'title' => true,
Expand Down Expand Up @@ -77,6 +78,13 @@ class Audio extends BaseType implements TypeInterface
*/
protected $fileSize;

/**
* 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.
*
* @var string
*/
protected $fileUniqueId;

/**
* @return int
*/
Expand Down Expand Up @@ -184,4 +192,20 @@ public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}

/**
* @return string
*/
public function getFileUniqueId()
{
return $this->fileUniqueId;
}

/**
* @param string $fileUniqueId
*/
public function setFileUniqueId($fileUniqueId)
{
$this->fileUniqueId = $fileUniqueId;
}
}
225 changes: 223 additions & 2 deletions src/Types/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ class Chat extends BaseType implements TypeInterface
'sticker_set_name' => true,
'can_set_sticker_set' => true,
'linked_chat_id' => true,
'location' => ChatLocation::class
'location' => ChatLocation::class,
'join_to_send_messages' => true,
'join_by_request' => true,
'message_auto_delete_time' => true,
'has_protected_content' => true,
'is_forum' => true,
'active_usernames' => true,
'emoji_status_custom_emoji_id' => true,
'has_private_forwards' => true,
'has_restricted_voice_and_video_messages' => true,
];

/**
Expand Down Expand Up @@ -163,6 +172,74 @@ class Chat extends BaseType implements TypeInterface
*/
protected $location;

/**
* Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat.
*
* @var bool
*/
protected $joinToSendMessages;

/**
* Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat.
*
* @var bool
*/
protected $joinByRequest;

/**
* Optional. Time after which all messages sent to the chat will be automatically deleted; in seconds. Returned
* only in getChat.
*
* @var int
*/
protected $messageAutoDeleteTime;

/**
* Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat.
*
* @var bool
*/
protected $hasProtectedContent;

/**
* Optional. True, if the supergroup chat is a forum (has topics enabled)
*
* @var bool
*/
protected $isForum;

/**
* Optional. If non-empty, the list of all active chat usernames;
* for private chats, supergroups and channels. Returned only in getChat.
*
* @var array[]
*/
protected $activeUsernames;

/**
* Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.
*
* @var string
*/
protected $emojiStatusCustomEmojiId;

/**
* Optional. True, if privacy settings of the other party in the private chat allows
* to use tg://user?id=<user_id> links only in chats with the user.
* Returned only in getChat.
*
* @var bool
*/
protected $hasPrivateForwards;

/**
* Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat.
* Returned only in getChat.
*
* @var bool
*/
protected $hasRestrictedVoiceAndVideoMessages;

/**
* @return int|string
*/
Expand Down Expand Up @@ -396,7 +473,7 @@ public function setStickerSetName($stickerSetName)
/**
* @return bool
*/
public function isCanSetStickerSet()
public function getCanSetStickerSet()
{
return $this->canSetStickerSet;
}
Expand Down Expand Up @@ -440,4 +517,148 @@ public function setLocation($location)
{
$this->location = $location;
}

/**
* @return bool
*/
public function getJoinToSendMessages()
{
return $this->joinToSendMessages;
}

/**
* @param bool $joinToSendMessages
*/
public function setJoinToSendMessages($joinToSendMessages)
{
$this->joinToSendMessages = $joinToSendMessages;
}

/**
* @return bool
*/
public function getJoinByRequest()
{
return $this->joinByRequest;
}

/**
* @param bool $joinByRequest
*/
public function setJoinByRequest($joinByRequest)
{
$this->joinByRequest = $joinByRequest;
}

/**
* @return int
*/
public function getMessageAutoDeleteTime()
{
return $this->messageAutoDeleteTime;
}

/**
* @param int $messageAutoDeleteTime
*/
public function setMessageAutoDeleteTime($messageAutoDeleteTime)
{
$this->messageAutoDeleteTime = $messageAutoDeleteTime;
}

/**
* @return bool
*/
public function getHasProtectedContent()
{
return $this->hasProtectedContent;
}

/**
* @param bool $hasProtectedContent
*/
public function setHasProtectedContent($hasProtectedContent)
{
$this->hasProtectedContent = $hasProtectedContent;
}

/**
* @return bool
*/
public function getIsForum()
{
return $this->isForum;
}

/**
* @param bool $isForum
*/
public function setIsForum($isForum)
{
$this->isForum = $isForum;
}

/**
* @return array
*/
public function getActiveUsernames()
{
return $this->activeUsernames;
}

/**
* @param array $activeUsernames
*/
public function setActiveUsernames($activeUsernames)
{
$this->activeUsernames = $activeUsernames;
}

/**
* @return bool
*/
public function getEmojiStatusCustomEmojiId()
{
return $this->emojiStatusCustomEmojiId;
}

/**
* @param bool $emojiStatusCustomEmojiId
*/
public function setEmojiStatusCustomEmojiId($emojiStatusCustomEmojiId)
{
$this->emojiStatusCustomEmojiId = $emojiStatusCustomEmojiId;
}

/**
* @return bool
*/
public function getHasPrivateForwards()
{
return $this->hasPrivateForwards;
}

/**
* @param bool $hasPrivateForwards
*/
public function setHasPrivateForwards($hasPrivateForwards)
{
$this->hasPrivateForwards = $hasPrivateForwards;
}

/**
* @return bool
*/
public function getHasRestrictedVoiceAndVideoMessages()
{
return $this->hasRestrictedVoiceAndVideoMessages;
}

/**
* @param bool $hasRestrictedVoiceAndVideoMessages
*/
public function setHasRestrictedVoiceAndVideoMessages($hasRestrictedVoiceAndVideoMessages)
{
$this->hasRestrictedVoiceAndVideoMessages = $hasRestrictedVoiceAndVideoMessages;
}
}
Loading