Add AnswerWebAppQuery method
This commit is contained in:
parent
c4b08b5ab9
commit
4ace03c02d
2 changed files with 57 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
|||
use TgBotLib\Methods\AddStickerToSet;
|
||||
use TgBotLib\Methods\AnswerCallbackQuery;
|
||||
use TgBotLib\Methods\AnswerInlineQuery;
|
||||
use TgBotLib\Methods\AnswerWebAppQuery;
|
||||
use TgBotLib\Methods\ApproveChatJoinRequest;
|
||||
use TgBotLib\Methods\BanChatMember;
|
||||
use TgBotLib\Methods\BanChatSenderChat;
|
||||
|
@ -235,6 +236,7 @@
|
|||
case SET_CUSTOM_EMOJI_STICKER_SET_THUMBNAIL = 'setCustomEmojiStickerSetThumbnail';
|
||||
case DELETE_STICKER_SET = 'deleteStickerSet';
|
||||
case ANSWER_INLINE_QUERY = 'answerInlineQuery';
|
||||
case ANSWER_WEB_APP_QUERY = 'answerWebAppQuery';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -361,7 +363,8 @@
|
|||
self::SET_STICKER_SET_THUMBNAIL => SetStickerSetThumbnail::execute($bot, $parameters),
|
||||
self::SET_CUSTOM_EMOJI_STICKER_SET_THUMBNAIL => SetCustomEmojiStickerSetThumbnail::execute($bot, $parameters),
|
||||
self::DELETE_STICKER_SET => DeleteStickerFromSet::execute($bot, $parameters),
|
||||
self::ANSWER_INLINE_QUERY => AnswerInlineQuery::execute($bot, $parameters)
|
||||
self::ANSWER_INLINE_QUERY => AnswerInlineQuery::execute($bot, $parameters),
|
||||
self::ANSWER_WEB_APP_QUERY => AnswerWebAppQuery::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
53
src/TgBotLib/Methods/AnswerWebAppQuery.php
Normal file
53
src/TgBotLib/Methods/AnswerWebAppQuery.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\SentWebAppMessage;
|
||||
|
||||
class AnswerWebAppQuery extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): SentWebAppMessage
|
||||
{
|
||||
if(isset($parameters['result']))
|
||||
{
|
||||
if($parameters['result'] instanceof ObjectTypeInterface)
|
||||
{
|
||||
$parameters['result'] = json_encode($parameters['result']->toArray());
|
||||
}
|
||||
|
||||
if(is_array($parameters['result']))
|
||||
{
|
||||
$parameters['result'] = json_encode($parameters['result']);
|
||||
}
|
||||
}
|
||||
|
||||
return SentWebAppMessage::fromArray(self::executeCurl(self::buildPost($bot, Methods::ANSWER_WEB_APP_QUERY->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'web_app_query_id',
|
||||
'result'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue