Add unpinAllChatMessages method

This commit is contained in:
netkas 2024-11-06 17:13:08 -05:00
parent 94d8922a49
commit 7ee714b36c
2 changed files with 40 additions and 0 deletions

View file

@ -56,6 +56,7 @@
use TgBotLib\Methods\SetWebhook; use TgBotLib\Methods\SetWebhook;
use TgBotLib\Methods\UnbanChatMember; use TgBotLib\Methods\UnbanChatMember;
use TgBotLib\Methods\UnbanChatSenderChat; use TgBotLib\Methods\UnbanChatSenderChat;
use TgBotLib\Methods\UnpinAllChatMessages;
use TgBotLib\Methods\UnpinChatMessage; use TgBotLib\Methods\UnpinChatMessage;
enum Methods : string enum Methods : string
@ -112,6 +113,7 @@
case SET_CHAT_DESCRIPTION = 'setChatDescription'; case SET_CHAT_DESCRIPTION = 'setChatDescription';
case PIN_CHAT_MESSAGE = 'pinChatMessage'; case PIN_CHAT_MESSAGE = 'pinChatMessage';
case UNPIN_CHAT_MESSAGE = 'unpinChatMessage'; case UNPIN_CHAT_MESSAGE = 'unpinChatMessage';
case UNPIN_ALL_CHAT_MESSAGES = 'unpinAllChatMessages';
/** /**
* Executes a command on the provided bot with the given parameters. * Executes a command on the provided bot with the given parameters.
@ -177,6 +179,7 @@
self::SET_CHAT_DESCRIPTION => SetChatDescription::execute($bot, $parameters), self::SET_CHAT_DESCRIPTION => SetChatDescription::execute($bot, $parameters),
self::PIN_CHAT_MESSAGE => PinChatMessage::execute($bot, $parameters), self::PIN_CHAT_MESSAGE => PinChatMessage::execute($bot, $parameters),
self::UNPIN_CHAT_MESSAGE => UnpinChatMessage::execute($bot, $parameters), self::UNPIN_CHAT_MESSAGE => UnpinChatMessage::execute($bot, $parameters),
self::UNPIN_ALL_CHAT_MESSAGES => UnpinAllChatMessages::execute($bot, $parameters),
}; };
} }
} }

View file

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