Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Update to Bot Api 6.7 #424

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Latest Version on Packagist](https://img.shields.io/packagist/v/nutgram/nutgram.svg?style=flat-square)](https://packagist.org/packages/nutgram/nutgram)
[![Total Downloads](https://img.shields.io/packagist/dt/nutgram/nutgram.svg?style=flat-square)](https://packagist.org/packages/nutgram/nutgram)
![GitHub](https://img.shields.io/github/license/nutgram/nutgram)
[![API](https://img.shields.io/badge/Telegram%20Bot%20API-6.6%09--%20March%209,%202023-blue.svg)](https://core.telegram.org/bots/api)
[![API](https://img.shields.io/badge/Telegram%20Bot%20API-6.7%09--%20April%2021,%202023-blue.svg)](https://core.telegram.org/bots/api)

[![Test Suite](https://github.com/nutgram/nutgram/actions/workflows/php.yml/badge.svg)](https://github.com/nutgram/nutgram/actions/workflows/php.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/86c4ca3dae8f64db80f7/maintainability)](https://codeclimate.com/github/nutgram/nutgram/maintainability)
Expand Down
28 changes: 28 additions & 0 deletions src/Telegram/Endpoints/AvailableMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use SergiX44\Nutgram\Telegram\Types\Command\BotCommandScope;
use SergiX44\Nutgram\Telegram\Types\Command\MenuButton;
use SergiX44\Nutgram\Telegram\Types\Description\BotDescription;
use SergiX44\Nutgram\Telegram\Types\Description\BotName;
use SergiX44\Nutgram\Telegram\Types\Description\BotShortDescription;
use SergiX44\Nutgram\Telegram\Types\Forum\ForumTopic;
use SergiX44\Nutgram\Telegram\Types\Input\InputMedia;
Expand Down Expand Up @@ -1467,6 +1468,33 @@ public function getMyCommands(array $opt = []): ?array
return $this->requestJson(__FUNCTION__, $opt, BotCommand::class);
}

/**
* Use this method to get the current bot name for the given user language. Returns BotName on success.
* @see https://core.telegram.org/bots/api#getmyname
* @param array{
* language_code?:string
* } $opt
* @return BotName|null
*/
public function getMyName(array $opt = []): ?BotName
{
return $this->requestJson(__FUNCTION__, $opt, BotName::class);
}

/**
* Use this method to change the bot's name. Returns True on success.
* @see https://core.telegram.org/bots/api#setmyname
* @param array{
* name?:string,
* language_code?:string
* } $opt
* @return bool|null
*/
public function setMyName(array $opt = []): ?bool
{
return $this->requestJson(__FUNCTION__, $opt, BotCommand::class);
}

/**
* 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
5 changes: 5 additions & 0 deletions src/Telegram/Types/Chat/ChatMemberUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ class ChatMemberUpdated extends BaseType
* 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;
}
13 changes: 13 additions & 0 deletions src/Telegram/Types/Description/BotName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace SergiX44\Nutgram\Telegram\Types\Description;

use SergiX44\Nutgram\Telegram\Types\BaseType;

class BotName extends BaseType
{
/**
* The bot's name
*/
public string $name;
}
4 changes: 4 additions & 0 deletions src/Telegram/Types/Forum/WriteAccessAllowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@

class WriteAccessAllowed extends BaseType
{
/**
* Optional. Name of the Web App which was launched from a link
*/
public ?string $web_app_name = null;
}
42 changes: 42 additions & 0 deletions src/Telegram/Types/Inline/InlineQueryResultsButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace SergiX44\Nutgram\Telegram\Types\Inline;

use SergiX44\Nutgram\Telegram\Types\BaseType;
use SergiX44\Nutgram\Telegram\Types\WebApp\WebAppInfo;

/**
* This object represents a button to be shown above inline query results.
* You must use exactly one of the optional fields.
* @see https://core.telegram.org/bots/api#inlinequeryresultsbutton
*/
class InlineQueryResultsButton extends BaseType
{
/**
* Label text on the button
*/
public string $text;

/**
* Optional. Description of the {@see https://core.telegram.org/bots/webapps 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. {@see https://core.telegram.org/bots/features#deep-linking 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 {@see https://core.telegram.org/bots/api#inlinekeyboardmarkup 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;
}
11 changes: 11 additions & 0 deletions src/Telegram/Types/Keyboard/InlineKeyboardButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class InlineKeyboardButton extends BaseType implements JsonSerializable
*/
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.
*
Expand All @@ -93,6 +99,7 @@ public function __construct(
?CallbackGame $callback_game = null,
?bool $pay = null,
?WebAppInfo $web_app = null,
?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null,
) {
parent::__construct();
$this->text = $text;
Expand All @@ -104,6 +111,7 @@ public function __construct(
$this->callback_game = $callback_game;
$this->pay = $pay;
$this->web_app = $web_app;
$this->switch_inline_query_chosen_chat = $switch_inline_query_chosen_chat;
}

public static function make(
Expand All @@ -116,6 +124,7 @@ public static function make(
?CallbackGame $callback_game = null,
?bool $pay = null,
?WebAppInfo $web_app = null,
?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null,
): InlineKeyboardButton {
return new self(
$text,
Expand All @@ -127,6 +136,7 @@ public static function make(
$callback_game,
$pay,
$web_app,
$switch_inline_query_chosen_chat,
);
}

Expand All @@ -139,6 +149,7 @@ public function jsonSerialize(): array
'callback_data' => $this->callback_data,
'switch_inline_query' => $this->switch_inline_query,
'switch_inline_query_current_chat' => $this->switch_inline_query_current_chat,
'switch_inline_query_chosen_chat' => $this->switch_inline_query_chosen_chat,
'callback_game' => $this->callback_game,
'pay' => $this->pay,
'web_app' => $this->web_app,
Expand Down
39 changes: 39 additions & 0 deletions src/Telegram/Types/Keyboard/SwitchInlineQueryChosenChat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace SergiX44\Nutgram\Telegram\Types\Keyboard;

use SergiX44\Nutgram\Telegram\Types\BaseType;

/**
* This object represents an inline button that switches the current user to inline mode in a chosen chat,
* with an optional default inline query.
* @see https://core.telegram.org/bots/api#switchinlinequerychosenchat
*/
class SwitchInlineQueryChosenChat extends BaseType
{
/**
* 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;
}