Skip to content

Commit a107062

Browse files
committed
Update code to reflect latest changes to the Bot API documentation
1 parent 0449fc0 commit a107062

12 files changed

Lines changed: 340 additions & 8 deletions

src/Layers/Generated.php

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
use Telepath\Telegram\ReplyParameters;
5050
use Telepath\Telegram\SentWebAppMessage;
5151
use Telepath\Telegram\ShippingOption;
52+
use Telepath\Telegram\StarTransactions;
5253
use Telepath\Telegram\Sticker;
5354
use Telepath\Telegram\StickerSet;
5455
use Telepath\Telegram\Update;
@@ -1702,9 +1703,10 @@ public function getMyDefaultAdministratorRights(?bool $for_channels = null): Cha
17021703
}
17031704

17041705
/**
1705-
* Use this method to edit text and <a href="https://core.telegram.org/bots/api#games">game</a> messages. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.
1706+
* Use this method to edit text and <a href="https://core.telegram.org/bots/api#games">game</a> messages. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
17061707
*
17071708
* @param string $text New text of the message, 1-4096 characters after entities parsing
1709+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
17081710
* @param int|string $chat_id Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
17091711
* @param int $message_id Required if <em>inline_message_id</em> is not specified. Identifier of the message to edit
17101712
* @param string $inline_message_id Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message
@@ -1717,6 +1719,7 @@ public function getMyDefaultAdministratorRights(?bool $for_channels = null): Cha
17171719
*/
17181720
public function editMessageText(
17191721
string $text,
1722+
?string $business_connection_id = null,
17201723
int|string|null $chat_id = null,
17211724
?int $message_id = null,
17221725
?string $inline_message_id = null,
@@ -1729,8 +1732,9 @@ public function editMessageText(
17291732
}
17301733

17311734
/**
1732-
* Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.
1735+
* Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
17331736
*
1737+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
17341738
* @param int|string $chat_id Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
17351739
* @param int $message_id Required if <em>inline_message_id</em> is not specified. Identifier of the message to edit
17361740
* @param string $inline_message_id Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message
@@ -1743,6 +1747,7 @@ public function editMessageText(
17431747
* @throws TelegramException
17441748
*/
17451749
public function editMessageCaption(
1750+
?string $business_connection_id = null,
17461751
int|string|null $chat_id = null,
17471752
?int $message_id = null,
17481753
?string $inline_message_id = null,
@@ -1756,9 +1761,10 @@ public function editMessageCaption(
17561761
}
17571762

17581763
/**
1759-
* Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.
1764+
* Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
17601765
*
17611766
* @param InputMedia $media A JSON-serialized object for a new media content of the message
1767+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
17621768
* @param int|string $chat_id Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
17631769
* @param int $message_id Required if <em>inline_message_id</em> is not specified. Identifier of the message to edit
17641770
* @param string $inline_message_id Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message
@@ -1768,6 +1774,7 @@ public function editMessageCaption(
17681774
*/
17691775
public function editMessageMedia(
17701776
InputMedia $media,
1777+
?string $business_connection_id = null,
17711778
int|string|null $chat_id = null,
17721779
?int $message_id = null,
17731780
?string $inline_message_id = null,
@@ -1781,6 +1788,7 @@ public function editMessageMedia(
17811788
*
17821789
* @param float $latitude Latitude of new location
17831790
* @param float $longitude Longitude of new location
1791+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
17841792
* @param int|string $chat_id Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
17851793
* @param int $message_id Required if <em>inline_message_id</em> is not specified. Identifier of the message to edit
17861794
* @param string $inline_message_id Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message
@@ -1795,6 +1803,7 @@ public function editMessageMedia(
17951803
public function editMessageLiveLocation(
17961804
float $latitude,
17971805
float $longitude,
1806+
?string $business_connection_id = null,
17981807
int|string|null $chat_id = null,
17991808
?int $message_id = null,
18001809
?string $inline_message_id = null,
@@ -1810,6 +1819,7 @@ public function editMessageLiveLocation(
18101819
/**
18111820
* Use this method to stop updating a live location message before <em>live_period</em> expires. On success, if the message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.
18121821
*
1822+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
18131823
* @param int|string $chat_id Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
18141824
* @param int $message_id Required if <em>inline_message_id</em> is not specified. Identifier of the message with live location to stop
18151825
* @param string $inline_message_id Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message
@@ -1818,6 +1828,7 @@ public function editMessageLiveLocation(
18181828
* @throws TelegramException
18191829
*/
18201830
public function stopMessageLiveLocation(
1831+
?string $business_connection_id = null,
18211832
int|string|null $chat_id = null,
18221833
?int $message_id = null,
18231834
?string $inline_message_id = null,
@@ -1827,8 +1838,9 @@ public function stopMessageLiveLocation(
18271838
}
18281839

18291840
/**
1830-
* Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.
1841+
* Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
18311842
*
1843+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
18321844
* @param int|string $chat_id Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
18331845
* @param int $message_id Required if <em>inline_message_id</em> is not specified. Identifier of the message to edit
18341846
* @param string $inline_message_id Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message
@@ -1837,6 +1849,7 @@ public function stopMessageLiveLocation(
18371849
* @throws TelegramException
18381850
*/
18391851
public function editMessageReplyMarkup(
1852+
?string $business_connection_id = null,
18401853
int|string|null $chat_id = null,
18411854
?int $message_id = null,
18421855
?string $inline_message_id = null,
@@ -1850,12 +1863,17 @@ public function editMessageReplyMarkup(
18501863
*
18511864
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
18521865
* @param int $message_id Identifier of the original message with the poll
1866+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message to be edited was sent
18531867
* @param InlineKeyboardMarkup $reply_markup A JSON-serialized object for a new message <a href="https://core.telegram.org/bots/features#inline-keyboards">inline keyboard</a>.
18541868
*
18551869
* @throws TelegramException
18561870
*/
1857-
public function stopPoll(int|string $chat_id, int $message_id, ?InlineKeyboardMarkup $reply_markup = null): Poll
1858-
{
1871+
public function stopPoll(
1872+
int|string $chat_id,
1873+
int $message_id,
1874+
?string $business_connection_id = null,
1875+
?InlineKeyboardMarkup $reply_markup = null,
1876+
): Poll {
18591877
return $this->raw('stopPoll', func_get_args());
18601878
}
18611879

@@ -2318,6 +2336,19 @@ public function answerPreCheckoutQuery(
23182336
return $this->raw('answerPreCheckoutQuery', func_get_args());
23192337
}
23202338

2339+
/**
2340+
* Returns the bot's Telegram Star transactions in chronological order. On success, returns a <a href="https://core.telegram.org/bots/api#startransactions">StarTransactions</a> object.
2341+
*
2342+
* @param int $offset Number of transactions to skip in the response
2343+
* @param int $limit The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100.
2344+
*
2345+
* @throws TelegramException
2346+
*/
2347+
public function getStarTransactions(?int $offset = null, ?int $limit = null): StarTransactions
2348+
{
2349+
return $this->raw('getStarTransactions', func_get_args());
2350+
}
2351+
23212352
/**
23222353
* Refunds a successful payment in <a href="https://t.me/BotNews/90">Telegram Stars</a>. Returns <em>True</em> on success.
23232354
*

src/Telegram/InlineKeyboardButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class InlineKeyboardButton extends Type
1919
/** <em>Optional</em>. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. */
2020
public ?string $url = null;
2121

22-
/** <em>Optional</em>. Data to be sent in a <a href="https://core.telegram.org/bots/api#callbackquery">callback query</a> to the bot when button is pressed, 1-64 bytes. Not supported for messages sent on behalf of a Telegram Business account. */
22+
/** <em>Optional</em>. Data to be sent in a <a href="https://core.telegram.org/bots/api#callbackquery">callback query</a> to the bot when the button is pressed, 1-64 bytes */
2323
public ?string $callback_data = null;
2424

2525
/** <em>Optional</em>. Description of the <a href="https://core.telegram.org/bots/webapps">Web App</a> that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method <a href="https://core.telegram.org/bots/api#answerwebappquery">answerWebAppQuery</a>. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account. */
@@ -46,7 +46,7 @@ class InlineKeyboardButton extends Type
4646
/**
4747
* @param string $text Label text on the button
4848
* @param string $url <em>Optional</em>. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings.
49-
* @param string $callback_data <em>Optional</em>. Data to be sent in a <a href="https://core.telegram.org/bots/api#callbackquery">callback query</a> to the bot when button is pressed, 1-64 bytes. Not supported for messages sent on behalf of a Telegram Business account.
49+
* @param string $callback_data <em>Optional</em>. Data to be sent in a <a href="https://core.telegram.org/bots/api#callbackquery">callback query</a> to the bot when the button is pressed, 1-64 bytes
5050
* @param WebAppInfo $web_app <em>Optional</em>. Description of the <a href="https://core.telegram.org/bots/webapps">Web App</a> that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method <a href="https://core.telegram.org/bots/api#answerwebappquery">answerWebAppQuery</a>. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account.
5151
* @param LoginUrl $login_url <em>Optional</em>. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the <a href="https://core.telegram.org/widgets/login">Telegram Login Widget</a>.
5252
* @param string $switch_inline_query <em>Optional</em>. 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. Not supported for messages sent on behalf of a Telegram Business account.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
use Telepath\Bot;
10+
use Telepath\Types\Factory;
11+
use Telepath\Types\Type;
12+
13+
/**
14+
* This object describes the state of a revenue withdrawal operation. Currently, it can be one of
15+
*/
16+
abstract class RevenueWithdrawalState extends Type implements Factory
17+
{
18+
/** Type of the state */
19+
public string $type;
20+
21+
public static function factory(array $data, ?Bot $bot = null): self
22+
{
23+
return match ($data['type']) {
24+
'pending' => new RevenueWithdrawalStatePending($data, $bot),
25+
'succeeded' => new RevenueWithdrawalStateSucceeded($data, $bot),
26+
'failed' => new RevenueWithdrawalStateFailed($data, $bot),
27+
};
28+
}
29+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
/**
10+
* The withdrawal failed and the transaction was refunded.
11+
*/
12+
class RevenueWithdrawalStateFailed extends RevenueWithdrawalState
13+
{
14+
/** Type of the state, always “failed” */
15+
public string $type = 'failed';
16+
17+
public static function make(): static
18+
{
19+
return new static([
20+
]);
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
/**
10+
* The withdrawal is in progress.
11+
*/
12+
class RevenueWithdrawalStatePending extends RevenueWithdrawalState
13+
{
14+
/** Type of the state, always “pending” */
15+
public string $type = 'pending';
16+
17+
public static function make(): static
18+
{
19+
return new static([
20+
]);
21+
}
22+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
/**
10+
* The withdrawal succeeded.
11+
*/
12+
class RevenueWithdrawalStateSucceeded extends RevenueWithdrawalState
13+
{
14+
/** Type of the state, always “succeeded” */
15+
public string $type = 'succeeded';
16+
17+
/** Date the withdrawal was completed in Unix time */
18+
public int $date;
19+
20+
/** An HTTPS URL that can be used to see transaction details */
21+
public string $url;
22+
23+
/**
24+
* @param int $date Date the withdrawal was completed in Unix time
25+
* @param string $url An HTTPS URL that can be used to see transaction details
26+
*/
27+
public static function make(int $date, string $url): static
28+
{
29+
return new static([
30+
'date' => $date,
31+
'url' => $url,
32+
]);
33+
}
34+
}

0 commit comments

Comments
 (0)