Add EditMessageCaption
This commit is contained in:
parent
d0519193eb
commit
0486a7f0ab
2 changed files with 80 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
||||||
use TgBotLib\Methods\EditChatSubscriptionInviteLink;
|
use TgBotLib\Methods\EditChatSubscriptionInviteLink;
|
||||||
use TgBotLib\Methods\EditForumTopic;
|
use TgBotLib\Methods\EditForumTopic;
|
||||||
use TgBotLib\Methods\EditGeneralForumTopic;
|
use TgBotLib\Methods\EditGeneralForumTopic;
|
||||||
|
use TgBotLib\Methods\EditMessageCaption;
|
||||||
use TgBotLib\Methods\EditMessageText;
|
use TgBotLib\Methods\EditMessageText;
|
||||||
use TgBotLib\Methods\ExportChatInviteLink;
|
use TgBotLib\Methods\ExportChatInviteLink;
|
||||||
use TgBotLib\Methods\ForwardMessage;
|
use TgBotLib\Methods\ForwardMessage;
|
||||||
|
@ -188,6 +189,7 @@
|
||||||
case SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'setMyDefaultAdministratorRights';
|
case SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'setMyDefaultAdministratorRights';
|
||||||
case GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'getMyDefaultAdministratorRights';
|
case GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'getMyDefaultAdministratorRights';
|
||||||
case EDIT_MESSAGE_TEXT = 'editMessageText';
|
case EDIT_MESSAGE_TEXT = 'editMessageText';
|
||||||
|
case EDIT_MESSAGE_CAPTION = 'editMessageCaption';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -291,6 +293,7 @@
|
||||||
self::SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => SetMyDefaultAdministratorRights::execute($bot, $parameters),
|
self::SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => SetMyDefaultAdministratorRights::execute($bot, $parameters),
|
||||||
self::GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => GetMyDefaultAdministratorRights::execute($bot, $parameters),
|
self::GET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => GetMyDefaultAdministratorRights::execute($bot, $parameters),
|
||||||
self::EDIT_MESSAGE_TEXT => EditMessageText::execute($bot, $parameters),
|
self::EDIT_MESSAGE_TEXT => EditMessageText::execute($bot, $parameters),
|
||||||
|
self::EDIT_MESSAGE_CAPTION => EditMessageCaption::execute($bot, $parameters),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
77
src/TgBotLib/Methods/EditMessageCaption.php
Normal file
77
src/TgBotLib/Methods/EditMessageCaption.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Methods;
|
||||||
|
|
||||||
|
use TgBotLib\Abstracts\Method;
|
||||||
|
use TgBotLib\Bot;
|
||||||
|
use TgBotLib\Enums\Methods;
|
||||||
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||||
|
use TgBotLib\Objects\Message;
|
||||||
|
use TgBotLib\Objects\MessageEntity;
|
||||||
|
|
||||||
|
class EditMessageCaption extends Method
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(Bot $bot, array $parameters = []): Message
|
||||||
|
{
|
||||||
|
if(isset($parameters['caption_entities']) && $parameters['caption_entities'])
|
||||||
|
{
|
||||||
|
$entities = [];
|
||||||
|
foreach($parameters['caption_entities'] as $entity)
|
||||||
|
{
|
||||||
|
if($entity instanceof MessageEntity)
|
||||||
|
{
|
||||||
|
$entities[] = $entity->toArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$entities[] = $entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$parameters['caption_entities'] = $entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($parameters['reply_markup']))
|
||||||
|
{
|
||||||
|
if ($parameters['reply_markup'] instanceof ObjectTypeInterface)
|
||||||
|
{
|
||||||
|
$parameters['reply_markup'] = json_encode($parameters['reply_markup']->toArray());
|
||||||
|
}
|
||||||
|
elseif (is_array($parameters['reply_markup']))
|
||||||
|
{
|
||||||
|
$parameters['reply_markup'] = json_encode($parameters['reply_markup']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::EDIT_MESSAGE_CAPTION->value, $parameters)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getRequiredParameters(): ?array
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getOptionalParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'business_connection_id',
|
||||||
|
'chat_id',
|
||||||
|
'message_id',
|
||||||
|
'inline_message_id',
|
||||||
|
'caption',
|
||||||
|
'parse_mode',
|
||||||
|
'caption_entities',
|
||||||
|
'show_caption_above_media',
|
||||||
|
'reply_markup'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue