Add method to unpin chat messages

This commit is contained in:
netkas 2024-11-06 17:11:45 -05:00
parent 2aca204f16
commit 94d8922a49
2 changed files with 43 additions and 0 deletions

View file

@ -56,6 +56,7 @@
use TgBotLib\Methods\SetWebhook;
use TgBotLib\Methods\UnbanChatMember;
use TgBotLib\Methods\UnbanChatSenderChat;
use TgBotLib\Methods\UnpinChatMessage;
enum Methods : string
{
@ -110,6 +111,7 @@
case SET_CHAT_TITLE = 'setChatTitle';
case SET_CHAT_DESCRIPTION = 'setChatDescription';
case PIN_CHAT_MESSAGE = 'pinChatMessage';
case UNPIN_CHAT_MESSAGE = 'unpinChatMessage';
/**
* Executes a command on the provided bot with the given parameters.
@ -174,6 +176,7 @@
self::SET_CHAT_TITLE => SetChatTitle::execute($bot, $parameters),
self::SET_CHAT_DESCRIPTION => SetChatDescription::execute($bot, $parameters),
self::PIN_CHAT_MESSAGE => PinChatMessage::execute($bot, $parameters),
self::UNPIN_CHAT_MESSAGE => UnpinChatMessage::execute($bot, $parameters),
};
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
class UnpinChatMessage extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): bool
{
return (bool)self::executeCurl(self::buildPost($bot, Methods::UNPIN_CHAT_MESSAGE->value, $parameters));
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return [
'chat_id'
];
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'business_connection_id',
'message_id'
];
}
}