Add StopPoll method
This commit is contained in:
parent
491137d5a4
commit
06b57feb9c
2 changed files with 58 additions and 0 deletions
|
@ -93,6 +93,7 @@
|
|||
use TgBotLib\Methods\SetMyShortDescription;
|
||||
use TgBotLib\Methods\SetWebhook;
|
||||
use TgBotLib\Methods\StopMessageLiveLocation;
|
||||
use TgBotLib\Methods\StopPoll;
|
||||
use TgBotLib\Methods\UnbanChatMember;
|
||||
use TgBotLib\Methods\UnbanChatSenderChat;
|
||||
use TgBotLib\Methods\UnhideGeneralForumTopic;
|
||||
|
@ -198,6 +199,7 @@
|
|||
case EDIT_MESSAGE_LIVE_LOCATION = 'editMessageLiveLocation';
|
||||
case STOP_MESSAGE_LIVE_LOCATION = 'stopMessageLiveLocation';
|
||||
case EDIT_MESSAGE_REPLY_MARKUP = 'editMessageReplyMarkup';
|
||||
case STOP_POLL = 'stopPoll';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -306,6 +308,7 @@
|
|||
self::EDIT_MESSAGE_LIVE_LOCATION => EditMessageLiveLocation::execute($bot, $parameters),
|
||||
self::STOP_MESSAGE_LIVE_LOCATION => StopMessageLiveLocation::execute($bot, $parameters),
|
||||
self::EDIT_MESSAGE_REPLY_MARKUP => EditMessageReplyMarkup::execute($bot, $parameters),
|
||||
self::STOP_POLL => StopPoll::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
55
src/TgBotLib/Methods/StopPoll.php
Normal file
55
src/TgBotLib/Methods/StopPoll.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Poll;
|
||||
|
||||
class StopPoll extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): Poll
|
||||
{
|
||||
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 Poll::fromArray(self::executeCurl(self::buildPost($bot, Methods::STOP_POLL->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'message_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'business_connection_id',
|
||||
'reply_markup'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue