Skip to content

Commit

Permalink
feat: update to bot api v7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateodioev committed Apr 3, 2024
1 parent c2b6a8b commit 4dfe238
Show file tree
Hide file tree
Showing 76 changed files with 2,007 additions and 158 deletions.
6 changes: 6 additions & 0 deletions src/Interfaces/TypesInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ public static function create(?array $update): ?static;
public static function default(): static;

public static function bulkCreate(?array $up): ?array;

/**
* If the object has sub-classes, returns an array of them. Otherwise, returns an empty array.
* @return TypesInterface[]
*/
public static function childs(): array;
}
2 changes: 1 addition & 1 deletion src/Types/Animation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare (strict_types = 1);

namespace Mateodioev\Bots\Telegram\Types;

Expand Down
2 changes: 1 addition & 1 deletion src/Types/Audio.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare (strict_types = 1);

namespace Mateodioev\Bots\Telegram\Types;

Expand Down
35 changes: 35 additions & 0 deletions src/Types/Birthdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare (strict_types = 1);

namespace Mateodioev\Bots\Telegram\Types;

use Mateodioev\Bots\Telegram\Config\FieldType;

/**
*
* @property int $day Day of the user's birth; 1-31
* @property int $month Month of the user's birth; 1-12
* @property int|null $year Optional. Year of the user's birth
*
* @method int day()
* @method int month()
* @method int|null year()
*
* @method static setDay(int $day)
* @method static setMonth(int $month)
* @method static setYear(int|null $year)
*
* @see https://core.telegram.org/bots/api#birthdate
*/
class Birthdate extends abstractType
{
protected function boot(): void
{
$this->fields = [
'day' => FieldType::single('integer'),
'month' => FieldType::single('integer'),
'year' => FieldType::optional('integer'),
];
}
}
16 changes: 15 additions & 1 deletion src/Types/BotCommandScope.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare (strict_types = 1);

namespace Mateodioev\Bots\Telegram\Types;

Expand All @@ -24,4 +24,18 @@ protected function boot(): void

];
}

public static function childs(): array
{
return [
BotCommandScopeDefault::class,
BotCommandScopeAllPrivateChats::class,
BotCommandScopeAllGroupChats::class,
BotCommandScopeAllChatAdministrators::class,
BotCommandScopeChat::class,
BotCommandScopeChatAdministrators::class,
BotCommandScopeChatMember::class,
];
}
// TODO: add method getChild(string $class): string
}
2 changes: 1 addition & 1 deletion src/Types/BotCommandScopeAllChatAdministrators.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare (strict_types = 1);

namespace Mateodioev\Bots\Telegram\Types;

Expand Down
2 changes: 1 addition & 1 deletion src/Types/BotCommandScopeAllGroupChats.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types=1);
declare (strict_types = 1);

namespace Mateodioev\Bots\Telegram\Types;

Expand Down
48 changes: 48 additions & 0 deletions src/Types/BusinessConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace Mateodioev\Bots\Telegram\Types;

use Mateodioev\Bots\Telegram\Config\FieldType;

/**
* Describes the connection of the bot with a business account.
*
* @property string $id Unique identifier of the business connection
* @property User $user Business account user that created the business connection
* @property int $user_chat_id Identifier of a private chat with the user who created the business connection. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
* @property int $date Date the connection was established in Unix time
* @property bool $can_reply True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours
* @property bool $is_enabled True, if the connection is active
*
* @method string id()
* @method User user()
* @method int userChatId()
* @method int date()
* @method bool canReply()
* @method bool isEnabled()
*
* @method static setId(string $id)
* @method static setUser(User $user)
* @method static setUserChatId(int $userChatId)
* @method static setDate(int $date)
* @method static setCanReply(bool $canReply)
* @method static setIsEnabled(bool $isEnabled)
*
* @see https://core.telegram.org/bots/api#businessconnection
*/
class BusinessConnection extends abstractType
{
protected function boot(): void
{
$this->fields = [
'id' => FieldType::single('string'),
'user' => FieldType::single(User::class),
'user_chat_id' => FieldType::single('integer'),
'date' => FieldType::single('integer'),
'can_reply' => FieldType::single('boolean'),
'is_enabled' => FieldType::single('boolean'),
];
}
}
36 changes: 36 additions & 0 deletions src/Types/BusinessIntro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Mateodioev\Bots\Telegram\Types;

use Mateodioev\Bots\Telegram\Config\FieldType;

/**
*
* @property string|null $title Optional. Title text of the business intro
* @property string|null $message Optional. Message text of the business intro
* @property Sticker|null $sticker Optional. Sticker of the business intro
*
* @method string|null title()
* @method string|null message()
* @method Sticker|null sticker()
*
* @method static setTitle(string|null $title)
* @method static setMessage(string|null $message)
* @method static setSticker(Sticker|null $sticker)
*
* @see https://core.telegram.org/bots/api#businessintro
*/
class BusinessIntro extends abstractType
{
protected function boot(): void
{
$this->fields = [
'title' => FieldType::optional('string'),
'message' => FieldType::optional('string'),
'sticker' => FieldType::optional(Sticker::class),
];
}
}
32 changes: 32 additions & 0 deletions src/Types/BusinessLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Mateodioev\Bots\Telegram\Types;

use Mateodioev\Bots\Telegram\Config\FieldType;

/**
*
* @property string $address Address of the business
* @property Location|null $location Optional. Location of the business
*
* @method string address()
* @method Location|null location()
*
* @method static setAddress(string $address)
* @method static setLocation(Location|null $location)
*
* @see https://core.telegram.org/bots/api#businesslocation
*/
class BusinessLocation extends abstractType
{
protected function boot(): void
{
$this->fields = [
'address' => FieldType::single('string'),
'location' => FieldType::optional(Location::class),
];
}
}
36 changes: 36 additions & 0 deletions src/Types/BusinessMessagesDeleted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Mateodioev\Bots\Telegram\Types;

use Mateodioev\Bots\Telegram\Config\FieldType;

/**
* This object is received when messages are deleted from a connected business account.
*
* @property string $business_connection_id Unique identifier of the business connection
* @property Chat $chat Information about a chat in the business account. The bot may not have access to the chat or the corresponding user.
* @property int[] $message_ids A JSON-serialized list of identifiers of deleted messages in the chat of the business account
*
* @method string businessConnectionId()
* @method Chat chat()
* @method int[] messageIds()
*
* @method static setBusinessConnectionId(string $businessConnectionId)
* @method static setChat(Chat $chat)
* @method static setMessageIds(int[] $messageIds)
*
* @see https://core.telegram.org/bots/api#businessmessagesdeleted
*/
class BusinessMessagesDeleted extends abstractType
{
protected function boot(): void
{
$this->fields = [
'business_connection_id' => FieldType::single('string'),
'chat' => FieldType::single(Chat::class),
'message_ids' => FieldType::multiple('integer'),
];
}
}
32 changes: 32 additions & 0 deletions src/Types/BusinessOpeningHours.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Mateodioev\Bots\Telegram\Types;

use Mateodioev\Bots\Telegram\Config\FieldType;

/**
*
* @property string $time_zone_name Unique name of the time zone for which the opening hours are defined
* @property BusinessOpeningHoursInterval[] $opening_hours List of time intervals describing business opening hours
*
* @method string timeZoneName()
* @method BusinessOpeningHoursInterval[] openingHours()
*
* @method static setTimeZoneName(string $timeZoneName)
* @method static setOpeningHours(BusinessOpeningHoursInterval[] $openingHours)
*
* @see https://core.telegram.org/bots/api#businessopeninghours
*/
class BusinessOpeningHours extends abstractType
{
protected function boot(): void
{
$this->fields = [
'time_zone_name' => FieldType::single('string'),
'opening_hours' => FieldType::multiple(BusinessOpeningHoursInterval::class),
];
}
}
32 changes: 32 additions & 0 deletions src/Types/BusinessOpeningHoursInterval.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Mateodioev\Bots\Telegram\Types;

use Mateodioev\Bots\Telegram\Config\FieldType;

/**
*
* @property int $opening_minute The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 24 60
* @property int $closing_minute The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 24 60
*
* @method int openingMinute()
* @method int closingMinute()
*
* @method static setOpeningMinute(int $openingMinute)
* @method static setClosingMinute(int $closingMinute)
*
* @see https://core.telegram.org/bots/api#businessopeninghoursinterval
*/
class BusinessOpeningHoursInterval extends abstractType
{
protected function boot(): void
{
$this->fields = [
'opening_minute' => FieldType::single('integer'),
'closing_minute' => FieldType::single('integer'),
];
}
}
8 changes: 4 additions & 4 deletions src/Types/CallbackQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
*
* @property string $id Unique identifier for this query
* @property User $from Sender
* @property Message|null $message Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old
* @property MaybeInaccessibleMessage|null $message Optional. Message sent by the bot with the callback button that originated the query
* @property string|null $inline_message_id Optional. Identifier of the message sent via the bot in inline mode, that originated the query.
* @property string $chat_instance Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.
* @property string|null $data Optional. Data associated with the callback button. Be aware that the message originated the query can contain no callback buttons with this data.
* @property string|null $game_short_name Optional. Short name of a Game to be returned, serves as the unique identifier for the game
*
* @method string id()
* @method User from()
* @method Message|null message()
* @method MaybeInaccessibleMessage|null message()
* @method string|null inlineMessageId()
* @method string chatInstance()
* @method string|null data()
* @method string|null gameShortName()
*
* @method static setId(string $id)
* @method static setFrom(User $from)
* @method static setMessage(Message|null $message)
* @method static setMessage(MaybeInaccessibleMessage|null $message)
* @method static setInlineMessageId(string|null $inlineMessageId)
* @method static setChatInstance(string $chatInstance)
* @method static setData(string|null $data)
Expand All @@ -42,7 +42,7 @@ protected function boot(): void
$this->fields = [
'id' => FieldType::single('string'),
'from' => FieldType::single(User::class),
'message' => FieldType::optional(Message::class),
'message' => FieldType::optional(MaybeInaccessibleMessage::class),
'inline_message_id' => FieldType::optional('string'),
'chat_instance' => FieldType::single('string'),
'data' => FieldType::optional('string'),
Expand Down
Loading

0 comments on commit 4dfe238

Please sign in to comment.