Skip to content

Commit

Permalink
Bot API 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
punyflash committed Jul 15, 2024
1 parent 4ef5ba1 commit 48ba72c
Show file tree
Hide file tree
Showing 29 changed files with 385 additions and 96 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<p align="center">
<a href="https://packagist.org/packages/westacks/telebot"><img src="https://poser.pugx.org/westacks/telebot/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://core.telegram.org/bots/api"><img src="https://img.shields.io/badge/Bot%20API-7.2-blue" alt="Bot API Version"></a>
<a href="https://core.telegram.org/bots/api"><img src="https://img.shields.io/badge/Bot%20API-7.3-blue" alt="Bot API Version"></a>
<a href="https://packagist.org/packages/westacks/telebot"><img src="https://poser.pugx.org/westacks/telebot/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/westacks/telebot"><img src="https://poser.pugx.org/westacks/telebot/license.svg" alt="License"></a>
<a href="https://github.com/westacks/telebot/actions/workflows/main.yml"><img src="https://github.com/westacks/telebot/actions/workflows/main.yml/badge.svg" alt="PHPUnit"></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p id="telebot" align="center">
<a href="https://github.com/westacks/telebot" class="app-name-link"><img src="/assets/logo.svg" alt="Project Logo"></a><br>
<a href="https://packagist.org/packages/westacks/telebot"><img src="https://poser.pugx.org/westacks/telebot/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://core.telegram.org/bots/api"><img src="https://img.shields.io/badge/Bot%20API-7.2-blue" alt="Bot API Version"></a>
<a href="https://core.telegram.org/bots/api"><img src="https://img.shields.io/badge/Bot%20API-7.3-blue" alt="Bot API Version"></a>
<a href="https://packagist.org/packages/westacks/telebot"><img src="https://poser.pugx.org/westacks/telebot/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/westacks/telebot"><img src="https://poser.pugx.org/westacks/telebot/license.svg" alt="License"></a>
</p>
Expand Down
2 changes: 2 additions & 0 deletions src/Methods/EditMessageLiveLocationMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property string $inline_message_id __Required: Optional__. Required if chat_id and message_id are not specified. Identifier of the inline message
* @property float $latitude __Required: Yes__. Latitude of new location
* @property float $longitude __Required: Yes__. Longitude of new location
* @property int $live_period __Required: Optional__. New period in seconds during which the location can be updated, starting from the message send date. If 0x7FFFFFFF is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current live_period by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then live_period remains unchanged
* @property float $horizontal_accuracy __Required: Optional__. The radius of uncertainty for the location, measured in meters; 0-1500
* @property int $heading __Required: Optional__. Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
* @property int $proximity_alert_radius __Required: Optional__. Maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
Expand All @@ -31,6 +32,7 @@ class EditMessageLiveLocationMethod extends TelegramMethod
'inline_message_id' => 'string',
'latitude' => 'double',
'longitude' => 'double',
'live_period' => 'integer',
'horizontal_accuracy' => 'double',
'heading' => 'integer',
'proximity_alert_radius' => 'integer',
Expand Down
2 changes: 1 addition & 1 deletion src/Methods/EditMessageTextMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use WeStacks\TeleBot\Contracts\TelegramMethod;
use WeStacks\TeleBot\Objects\InlineKeyboardMarkup;
use WeStacks\TeleBot\Objects\LinkPreviewOptions;
use WeStacks\TeleBot\Objects\Message;
use WeStacks\TeleBot\Objects\MessageEntity;
use WeStacks\TeleBot\Objects\LinkPreviewOptions;

/**
* Use this method to edit text and [game](https://core.telegram.org/bots/api#games) messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned.
Expand Down
2 changes: 1 addition & 1 deletion src/Methods/GetChatMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GetChatMethod extends TelegramMethod
{
protected string $method = 'getChat';

protected string $expect = 'Chat';
protected string $expect = 'ChatFullInfo';

protected array $parameters = [
'chat_id' => 'string',
Expand Down
3 changes: 1 addition & 2 deletions src/Methods/GetUserChatBoostsMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace WeStacks\TeleBot\Methods;

use WeStacks\TeleBot\Contracts\TelegramMethod;
use WeStacks\TeleBot\Objects\Update;
use WeStacks\TeleBot\Objects\UserChatBoosts;

/**
Expand All @@ -26,7 +25,7 @@ class GetUserChatBoostsMethod extends TelegramMethod
public function mock($arguments)
{
return new UserChatBoosts([
'boosts' => []
'boosts' => [],
]);
}
}
2 changes: 1 addition & 1 deletion src/Methods/SendMessageMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use WeStacks\TeleBot\Contracts\TelegramMethod;
use WeStacks\TeleBot\Objects\Keyboard;
use WeStacks\TeleBot\Objects\LinkPreviewOptions;
use WeStacks\TeleBot\Objects\Message;
use WeStacks\TeleBot\Objects\MessageEntity;
use WeStacks\TeleBot\Objects\ReplyParameters;
use WeStacks\TeleBot\Objects\LinkPreviewOptions;

/**
* Use this method to send text messages. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.
Expand Down
7 changes: 5 additions & 2 deletions src/Methods/SendPollMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WeStacks\TeleBot\Methods;

use WeStacks\TeleBot\Contracts\TelegramMethod;
use WeStacks\TeleBot\Objects\InputPollOption;
use WeStacks\TeleBot\Objects\Keyboard;
use WeStacks\TeleBot\Objects\Message;
use WeStacks\TeleBot\Objects\MessageEntity;
Expand All @@ -14,7 +15,8 @@
* @property string $business_connection_id __Required: Optional__. Unique identifier of the business connection on behalf of which the message will be sent* @property string $chat_id __Required: Yes__. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @property int $message_thread_id __Required: Optional__. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
* @property string $question __Required: Yes__. Poll question, 1-300 characters
* @property string[] $options __Required: Yes__. A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
* @property string $options_parse_mode __Required: Optional__. Mode for parsing entities in the question. See formatting options for more details. Currently, only custom emoji entities are allowed
* @property InputPollOption[] $options __Required: Yes__. A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
* @property bool $is_anonymous __Required: Optional__. True, if the poll needs to be anonymous, defaults to True
* @property string $type __Required: Optional__. Poll type, “quiz” or “regular”, defaults to “regular”
* @property bool $allows_multiple_answers __Required: Optional__. True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False
Expand All @@ -41,7 +43,8 @@ class SendPollMethod extends TelegramMethod
'chat_id' => 'string',
'message_thread_id' => 'integer',
'question' => 'string',
'options' => 'string[]',
'question_parse_mode' => 'string',
'options' => 'InputPollOption[]',
'is_anonymous' => 'boolean',
'type' => 'string',
'allows_multiple_answers' => 'boolean',
Expand Down
33 changes: 33 additions & 0 deletions src/Objects/BackgroundFill.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace WeStacks\TeleBot\Objects;

use WeStacks\TeleBot\Contracts\TelegramObject;
use WeStacks\TeleBot\Exceptions\TeleBotException;

/**
* This object describes the way a background is filled based on the selected colors. Currently, it can be one of
*
* - [BackgroundFillSolid](https://core.telegram.org/bots/api#backgroundfillsolid)
* - [BackgroundFillGradient](https://core.telegram.org/bots/api#backgroundfillgradient)
* - [BackgroundFillFreeformGradient](https://core.telegram.org/bots/api#backgroundfillfreeformgradient)
*/
abstract class BackgroundFill extends TelegramObject
{
protected static $types = [
'solid' => BackgroundFillSolid::class,
'gradient' => BackgroundFillGradient::class,
'freeform_gradient' => BackgroundFillFreeformGradient::class,
];

public static function create($object)
{
$object = (array) $object;

if ($class = static::$types[$object['type'] ?? null] ?? null) {
return new $class($object);
}

throw new TeleBotException('Cannot cast value of type '.gettype($object).' to type '.static::class);
}
}
17 changes: 17 additions & 0 deletions src/Objects/BackgroundFillFreeformGradient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace WeStacks\TeleBot\Objects;

/**
* The background is a freeform gradient that rotates after every message in the chat.
*
* @property string $type Type of the background fill, always “freeform_gradient”
* @property int[] $colors A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format
*/
class BackgroundFillFreeformGradient extends BackgroundFill
{
protected $attributes = [
'type' => 'string',
'colors' => 'integer[]',
];
}
21 changes: 21 additions & 0 deletions src/Objects/BackgroundFillGradient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace WeStacks\TeleBot\Objects;

/**
* The background is a gradient fill.
*
* @property string $type Type of the background fill, always “gradient”
* @property int $top_color Top color of the gradient in the RGB24 format
* @property int $bottom_color Bottom color of the gradient in the RGB24 format
* @property int $rotation_angle Clockwise rotation angle of the background fill in degrees; 0-359
*/
class BackgroundFillGradient extends BackgroundFill
{
protected $attributes = [
'type' => 'string',
'top_color' => 'integer',
'bottom_color' => 'integer',
'rotation_angle' => 'integer',
];
}
17 changes: 17 additions & 0 deletions src/Objects/BackgroundFillSolid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace WeStacks\TeleBot\Objects;

/**
* The background is filled using the selected color.
*
* @property string $type Type of the background, always “chat_theme”
* @property int $color The color of the background fill in the RGB24 format
*/
class BackgroundFillSolid extends BackgroundFill
{
protected $attributes = [
'type' => 'string',
'color' => 'integer',
];
}
35 changes: 35 additions & 0 deletions src/Objects/BackgroundType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace WeStacks\TeleBot\Objects;

use WeStacks\TeleBot\Contracts\TelegramObject;
use WeStacks\TeleBot\Exceptions\TeleBotException;

/**
* This object describes the type of a background. Currently, it can be one of
*
* - [BackgroundTypeFill](https://core.telegram.org/bots/api#backgroundtypefill)
* - [BackgroundTypeWallpaper](https://core.telegram.org/bots/api#backgroundtypewallpaper)
* - [BackgroundTypePattern](https://core.telegram.org/bots/api#backgroundtypepattern)
* - [BackgroundTypeChatTheme](https://core.telegram.org/bots/api#backgroundtypechattheme)
*/
abstract class BackgroundType extends TelegramObject
{
protected static $types = [
'fill' => BackgroundTypeFill::class,
'wallpaper' => BackgroundTypeWallpaper::class,
'pattern' => BackgroundTypePattern::class,
'chat_theme' => BackgroundTypeChatTheme::class,
];

public static function create($object)
{
$object = (array) $object;

if ($class = static::$types[$object['type'] ?? null] ?? null) {
return new $class($object);
}

throw new TeleBotException('Cannot cast value of type '.gettype($object).' to type '.static::class);
}
}
17 changes: 17 additions & 0 deletions src/Objects/BackgroundTypeChatTheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace WeStacks\TeleBot\Objects;

/**
* The background is taken directly from a built-in chat theme.
*
* @property string $type Type of the background, always “chat_theme”
* @property string $theme_name Name of the chat theme, which is usually an emoji
*/
class BackgroundTypeChatTheme extends BackgroundType
{
protected $attributes = [
'type' => 'string',
'theme_name' => 'string',
];
}
19 changes: 19 additions & 0 deletions src/Objects/BackgroundTypeFill.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace WeStacks\TeleBot\Objects;

/**
* The background is automatically filled based on the selected colors.
*
* @property string $type The type of the background
* @property BackgroundFillSolid|BackgroundFillGradient|BackgroundFillFreeformGradient $fill The background fill
* @property int $dark_theme_dimming Dimming of the background in dark themes, as a percentage; 0-100
*/
class BackgroundTypeFill extends BackgroundType
{
protected $attributes = [
'type' => 'string',
'fill' => 'BackgroundFill',
'dark_theme_dimming' => 'integer',
];
}
25 changes: 25 additions & 0 deletions src/Objects/BackgroundTypePattern.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace WeStacks\TeleBot\Objects;

/**
* The background is a PNG or TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user.
*
* @property string $type Type of the background, always “pattern”
* @property Document $document Document with the pattern
* @property BackgroundFillSolid|BackgroundFillGradient|BackgroundFillFreeformGradient $fill The background fill that is combined with the pattern
* @property int $intensity Intensity of the pattern when it is shown above the filled background; 0-100
* @property bool $is_inverted Optional. True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only
* @property bool $is_moving Optional. True, if the background moves slightly when the device is tilted
*/
class BackgroundTypePattern extends BackgroundType
{
protected $attributes = [
'type' => 'string',
'document' => 'Document',
'fill' => 'BackgroundFill',
'intensity' => 'integer',
'is_inverted' => 'bool',
'is_moving' => 'bool',
];
}
23 changes: 23 additions & 0 deletions src/Objects/BackgroundTypeWallpaper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace WeStacks\TeleBot\Objects;

/**
* The background is a wallpaper in the JPEG format.
*
* @property string $type Type of the background, always “wallpaper”
* @property Document $document Document with the wallpaper
* @property int $dark_theme_dimming Dimming of the background in dark themes, as a percentage; 0-100
* @property bool $is_blurred Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12
* @property bool $is_moving Optional. True, if the background moves slightly when the device is tilted
*/
class BackgroundTypeWallpaper extends BackgroundType
{
protected $attributes = [
'type' => 'string',
'document' => 'Document',
'dark_theme_dimming' => 'integer',
'is_blurred' => 'boolean',
'is_moving' => 'boolean',
];
}
Loading

0 comments on commit 48ba72c

Please sign in to comment.