Add CreateForumTopic method to TgBotLib

This commit is contained in:
netkas 2024-11-06 19:26:43 -05:00
parent 4accf1713c
commit 530cc3e402
2 changed files with 44 additions and 0 deletions

View file

@ -130,6 +130,7 @@
case SET_CHAT_STICKER_SET = 'setChatStickerSet';
case DELETE_CHAT_STICKER_SET = 'deleteChatStickerSet';
case GET_FORUM_TOPIC_ICON_STICKERS = 'getForumTopicIconStickers';
case CREATE_FORUM_TOPIC = 'createForumTopic';
/**
* Executes a command on the provided bot with the given parameters.
@ -204,6 +205,7 @@
self::SET_CHAT_STICKER_SET => SetChatStickerSet::execute($bot, $parameters),
self::DELETE_CHAT_STICKER_SET => DeleteChatStickerSet::execute($bot, $parameters),
self::GET_FORUM_TOPIC_ICON_STICKERS => GetForumTopicIconStickers::execute($bot, $parameters),
self::CREATE_FORUM_TOPIC => CreateChatSubscriptionInviteLink::execute($bot, $parameters),
};
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
use TgBotLib\Objects\ForumTopic;
class CreateForumTopic extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): ForumTopic
{
return ForumTopic::fromArray(self::executeCurl(self::buildPost($bot, Methods::CREATE_FORUM_TOPIC->value, $parameters)));
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return [
'chat_id',
'name'
];
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'icon_color',
'icon_custom_emoji_id'
];
}
}