Add AnswerCallbackQuery method to handle callback queries
This commit is contained in:
parent
17369210d5
commit
be210c5411
2 changed files with 45 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
use TgBotLib\Bot;
|
use TgBotLib\Bot;
|
||||||
use TgBotLib\Exceptions\TelegramException;
|
use TgBotLib\Exceptions\TelegramException;
|
||||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||||
|
use TgBotLib\Methods\AnswerCallbackQuery;
|
||||||
use TgBotLib\Methods\ApproveChatJoinRequest;
|
use TgBotLib\Methods\ApproveChatJoinRequest;
|
||||||
use TgBotLib\Methods\BanChatMember;
|
use TgBotLib\Methods\BanChatMember;
|
||||||
use TgBotLib\Methods\BanChatSenderChat;
|
use TgBotLib\Methods\BanChatSenderChat;
|
||||||
|
@ -154,6 +155,7 @@
|
||||||
case HIDE_GENERAL_FORUM_TOPIC = 'hideGeneralForumTopic';
|
case HIDE_GENERAL_FORUM_TOPIC = 'hideGeneralForumTopic';
|
||||||
case UNHIDE_GENERAL_FORUM_TOPIC = 'unhideGeneralForumTopic';
|
case UNHIDE_GENERAL_FORUM_TOPIC = 'unhideGeneralForumTopic';
|
||||||
case UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES = 'unpinAllGeneralForumTopicMessages';
|
case UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES = 'unpinAllGeneralForumTopicMessages';
|
||||||
|
case ANSWER_CALLBACK_QUERY = 'answerCallbackQuery';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -240,6 +242,7 @@
|
||||||
self::HIDE_GENERAL_FORUM_TOPIC => HideGeneralForumTopic::execute($bot, $parameters),
|
self::HIDE_GENERAL_FORUM_TOPIC => HideGeneralForumTopic::execute($bot, $parameters),
|
||||||
self::UNHIDE_GENERAL_FORUM_TOPIC => UnhideGeneralForumTopic::execute($bot, $parameters),
|
self::UNHIDE_GENERAL_FORUM_TOPIC => UnhideGeneralForumTopic::execute($bot, $parameters),
|
||||||
self::UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES => UnpinAllGeneralForumTopicMessages::execute($bot, $parameters),
|
self::UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES => UnpinAllGeneralForumTopicMessages::execute($bot, $parameters),
|
||||||
|
self::ANSWER_CALLBACK_QUERY => AnswerCallbackQuery::execute($bot, $parameters),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
42
src/TgBotLib/Methods/AnswerCallbackQuery.php
Normal file
42
src/TgBotLib/Methods/AnswerCallbackQuery.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Methods;
|
||||||
|
|
||||||
|
use TgBotLib\Abstracts\Method;
|
||||||
|
use TgBotLib\Bot;
|
||||||
|
use TgBotLib\Enums\Methods;
|
||||||
|
|
||||||
|
class AnswerCallbackQuery extends Method
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(Bot $bot, array $parameters = []): true
|
||||||
|
{
|
||||||
|
return (bool)(self::executeCurl(self::buildPost($bot, Methods::ANSWER_CALLBACK_QUERY->value, $parameters)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getRequiredParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'callback_query_id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getOptionalParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'text',
|
||||||
|
'show_alert',
|
||||||
|
'url',
|
||||||
|
'cache_time'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue