Skip to content

Commit

Permalink
Update code to reflect latest changes to the API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TiiFuchs committed Apr 21, 2023
1 parent 28008bd commit 6e598d4
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 8 deletions.
34 changes: 28 additions & 6 deletions src/Layers/Generated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Telepath\Telegram\ForceReply;
use Telepath\Telegram\InlineKeyboardMarkup;
use Telepath\Telegram\InlineQueryResult;
use Telepath\Telegram\InlineQueryResultsButton;
use Telepath\Telegram\InputMedia;
use Telepath\Telegram\InputMediaAudio;
use Telepath\Telegram\InputMediaDocument;
Expand All @@ -34,7 +35,7 @@ abstract class Generated extends Base
/**
* Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.
*
* @param int $offset Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
* @param int $offset Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.
* @param int $limit Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
* @param int $timeout Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
* @param string[] $allowed_updates A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.
Expand Down Expand Up @@ -1324,6 +1325,29 @@ public function getMyCommands(?BotCommandScope $scope = null, ?string $language_
return $this->raw('getMyCommands', func_get_args());
}

/**
* Use this method to change the bot's name. Returns True on success.
*
* @param string $name New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
* @param string $language_code A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
* @throws \Telepath\Exceptions\TelegramException
*/
public function setMyName(?string $name = null, ?string $language_code = null)
{
return $this->raw('setMyName', func_get_args());
}

/**
* Use this method to get the current bot name for the given user language. Returns BotName on success.
*
* @param string $language_code A two-letter ISO 639-1 language code or an empty string
* @throws \Telepath\Exceptions\TelegramException
*/
public function getMyName(?string $language_code = null)
{
return $this->raw('getMyName', func_get_args());
}

/**
* Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success.
*
Expand Down Expand Up @@ -1793,10 +1817,9 @@ public function deleteStickerSet(string $name)
* @param string $inline_query_id Unique identifier for the answered query
* @param InlineQueryResult[] $results A JSON-serialized array of results for the inline query
* @param int $cache_time The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
* @param bool $is_personal Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
* @param bool $is_personal Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query.
* @param string $next_offset Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
* @param string $switch_pm_text If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
* @param string $switch_pm_parameter Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
* @param InlineQueryResultsButton $button A JSON-serialized object describing a button to be shown above inline query results
* @throws \Telepath\Exceptions\TelegramException
*/
public function answerInlineQuery(
Expand All @@ -1805,8 +1828,7 @@ public function answerInlineQuery(
?int $cache_time = null,
?bool $is_personal = null,
?string $next_offset = null,
?string $switch_pm_text = null,
?string $switch_pm_parameter = null,
?InlineQueryResultsButton $button = null,
): bool {
return $this->raw('answerInlineQuery', func_get_args());
}
Expand Down
28 changes: 28 additions & 0 deletions src/Telegram/BotName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* This object represents the bot's name.
*/
class BotName extends Type
{
/** The bot's name */
public string $name;

/**
* @param string $name The bot's name
*/
public static function make(string $name): static
{
return new static([
'name' => $name,
]);
}
}
6 changes: 6 additions & 0 deletions src/Telegram/ChatMemberUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ class ChatMemberUpdated extends Type
/** Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. */
public ?ChatInviteLink $invite_link = null;

/** Optional. True, if the user joined the chat via a chat folder invite link */
public ?bool $via_chat_folder_invite_link = null;

/**
* @param Chat $chat Chat the user belongs to
* @param User $from Performer of the action, which resulted in the change
* @param int $date Date the change was done in Unix time
* @param ChatMember $old_chat_member Previous information about the chat member
* @param ChatMember $new_chat_member New information about the chat member
* @param ChatInviteLink $invite_link Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
* @param bool $via_chat_folder_invite_link Optional. True, if the user joined the chat via a chat folder invite link
*/
public static function make(
Chat $chat,
Expand All @@ -46,6 +50,7 @@ public static function make(
ChatMember $old_chat_member,
ChatMember $new_chat_member,
?ChatInviteLink $invite_link = null,
?bool $via_chat_folder_invite_link = null,
): static {
return new static([
'chat' => $chat,
Expand All @@ -54,6 +59,7 @@ public static function make(
'old_chat_member' => $old_chat_member,
'new_chat_member' => $new_chat_member,
'invite_link' => $invite_link,
'via_chat_folder_invite_link' => $via_chat_folder_invite_link,
]);
}
}
6 changes: 6 additions & 0 deletions src/Telegram/InlineKeyboardButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class InlineKeyboardButton extends Type
/** Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. */
public ?string $switch_inline_query_current_chat = null;

/** Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field */
public ?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null;

/** Optional. Description of the game that will be launched when the user presses the button.NOTE: This type of button must always be the first button in the first row. */
public ?CallbackGame $callback_game = null;

Expand All @@ -48,6 +51,7 @@ class InlineKeyboardButton extends Type
* @param LoginUrl $login_url Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.
* @param string $switch_inline_query Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted.Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.
* @param string $switch_inline_query_current_chat Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options.
* @param SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field
* @param CallbackGame $callback_game Optional. Description of the game that will be launched when the user presses the button.NOTE: This type of button must always be the first button in the first row.
* @param bool $pay Optional. Specify True, to send a Pay button.NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.
*/
Expand All @@ -59,6 +63,7 @@ public static function make(
?LoginUrl $login_url = null,
?string $switch_inline_query = null,
?string $switch_inline_query_current_chat = null,
?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null,
?CallbackGame $callback_game = null,
?bool $pay = null,
): static {
Expand All @@ -70,6 +75,7 @@ public static function make(
'login_url' => $login_url,
'switch_inline_query' => $switch_inline_query,
'switch_inline_query_current_chat' => $switch_inline_query_current_chat,
'switch_inline_query_chosen_chat' => $switch_inline_query_chosen_chat,
'callback_game' => $callback_game,
'pay' => $pay,
]);
Expand Down
38 changes: 38 additions & 0 deletions src/Telegram/InlineQueryResultsButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* This object represents a button to be shown above inline query results. You must use exactly one of the optional fields.
*/
class InlineQueryResultsButton extends Type
{
/** Label text on the button */
public string $text;

/** Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method web_app_switch_inline_query inside the Web App. */
public ?WebAppInfo $web_app = null;

/** Optional. Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. */
public ?string $start_parameter = null;

/**
* @param string $text Label text on the button
* @param WebAppInfo $web_app Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method web_app_switch_inline_query inside the Web App.
* @param string $start_parameter Optional. Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
*/
public static function make(string $text, ?WebAppInfo $web_app = null, ?string $start_parameter = null): static
{
return new static([
'text' => $text,
'web_app' => $web_app,
'start_parameter' => $start_parameter,
]);
}
}
53 changes: 53 additions & 0 deletions src/Telegram/SwitchInlineQueryChosenChat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.
*/
class SwitchInlineQueryChosenChat extends Type
{
/** Optional. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted */
public ?string $query = null;

/** Optional. True, if private chats with users can be chosen */
public ?bool $allow_user_chats = null;

/** Optional. True, if private chats with bots can be chosen */
public ?bool $allow_bot_chats = null;

/** Optional. True, if group and supergroup chats can be chosen */
public ?bool $allow_group_chats = null;

/** Optional. True, if channel chats can be chosen */
public ?bool $allow_channel_chats = null;

/**
* @param string $query Optional. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted
* @param bool $allow_user_chats Optional. True, if private chats with users can be chosen
* @param bool $allow_bot_chats Optional. True, if private chats with bots can be chosen
* @param bool $allow_group_chats Optional. True, if group and supergroup chats can be chosen
* @param bool $allow_channel_chats Optional. True, if channel chats can be chosen
*/
public static function make(
?string $query = null,
?bool $allow_user_chats = null,
?bool $allow_bot_chats = null,
?bool $allow_group_chats = null,
?bool $allow_channel_chats = null,
): static {
return new static([
'query' => $query,
'allow_user_chats' => $allow_user_chats,
'allow_bot_chats' => $allow_bot_chats,
'allow_group_chats' => $allow_group_chats,
'allow_channel_chats' => $allow_channel_chats,
]);
}
}
11 changes: 9 additions & 2 deletions src/Telegram/WriteAccessAllowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
use Telepath\Types\Type;

/**
* This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.
* This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.
*/
class WriteAccessAllowed extends Type
{
public static function make(): static
/** Optional. Name of the Web App which was launched from a link */
public ?string $web_app_name = null;

/**
* @param string $web_app_name Optional. Name of the Web App which was launched from a link
*/
public static function make(?string $web_app_name = null): static
{
return new static([
'web_app_name' => $web_app_name,
]);
}
}

0 comments on commit 6e598d4

Please sign in to comment.