Add DeleteMessages method
This commit is contained in:
parent
ae7facc255
commit
c01b8653c5
2 changed files with 47 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
|||
use TgBotLib\Methods\DeleteChatStickerSet;
|
||||
use TgBotLib\Methods\DeleteForumTopic;
|
||||
use TgBotLib\Methods\DeleteMessage;
|
||||
use TgBotLib\Methods\DeleteMessages;
|
||||
use TgBotLib\Methods\DeleteMyCommands;
|
||||
use TgBotLib\Methods\DeleteWebhook;
|
||||
use TgBotLib\Methods\EditChatInviteLink;
|
||||
|
@ -202,6 +203,7 @@
|
|||
case EDIT_MESSAGE_REPLY_MARKUP = 'editMessageReplyMarkup';
|
||||
case STOP_POLL = 'stopPoll';
|
||||
case DELETE_MESSAGE = 'deleteMessage';
|
||||
case DELETE_MESSAGES = 'deleteMessages';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -312,6 +314,7 @@
|
|||
self::EDIT_MESSAGE_REPLY_MARKUP => EditMessageReplyMarkup::execute($bot, $parameters),
|
||||
self::STOP_POLL => StopPoll::execute($bot, $parameters),
|
||||
self::DELETE_MESSAGE => DeleteMessage::execute($bot, $parameters),
|
||||
self::DELETE_MESSAGES => DeleteMessages::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
44
src/TgBotLib/Methods/DeleteMessages.php
Normal file
44
src/TgBotLib/Methods/DeleteMessages.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class DeleteMessages extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
if (isset($parameters['message_ids']) && is_array($parameters['message_ids']))
|
||||
{
|
||||
$parameters['message_ids'] = json_encode($parameters['message_ids']);
|
||||
}
|
||||
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::DELETE_MESSAGES->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'message_ids'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue