Skip to content

Commit

Permalink
Added static make methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TiiFuchs committed Apr 30, 2022
1 parent e02e1a9 commit bd1c9e1
Show file tree
Hide file tree
Showing 133 changed files with 3,472 additions and 388 deletions.
44 changes: 40 additions & 4 deletions src/Telegram/Animation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,50 @@ class Animation extends \Tii\Telepath\Type
public int $duration;

/** Optional. Animation thumbnail as defined by sender */
public ?PhotoSize $thumb;
public ?PhotoSize $thumb = null;

/** Optional. Original animation filename as defined by sender */
public ?string $file_name;
public ?string $file_name = null;

/** Optional. MIME type of the file as defined by sender */
public ?string $mime_type;
public ?string $mime_type = null;

/** Optional. File size in bytes */
public ?int $file_size;
public ?int $file_size = null;


/**
* @param string $file_id Identifier for this file, which can be used to download or reuse the file
* @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
* @param int $width Video width as defined by sender
* @param int $height Video height as defined by sender
* @param int $duration Duration of the video in seconds as defined by sender
* @param PhotoSize $thumb Optional. Animation thumbnail as defined by sender
* @param string $file_name Optional. Original animation filename as defined by sender
* @param string $mime_type Optional. MIME type of the file as defined by sender
* @param int $file_size Optional. File size in bytes
*/
public static function make(
string $file_id,
string $file_unique_id,
int $width,
int $height,
int $duration,
?PhotoSize $thumb = null,
?string $file_name = null,
?string $mime_type = null,
?int $file_size = null
): static {
return new static([
'file_id' => $file_id,
'file_unique_id' => $file_unique_id,
'width' => $width,
'height' => $height,
'duration' => $duration,
'thumb' => $thumb,
'file_name' => $file_name,
'mime_type' => $mime_type,
'file_size' => $file_size,
]);
}
}
48 changes: 42 additions & 6 deletions src/Telegram/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,56 @@ class Audio extends \Tii\Telepath\Type
public int $duration;

/** Optional. Performer of the audio as defined by sender or by audio tags */
public ?string $performer;
public ?string $performer = null;

/** Optional. Title of the audio as defined by sender or by audio tags */
public ?string $title;
public ?string $title = null;

/** Optional. Original filename as defined by sender */
public ?string $file_name;
public ?string $file_name = null;

/** Optional. MIME type of the file as defined by sender */
public ?string $mime_type;
public ?string $mime_type = null;

/** Optional. File size in bytes */
public ?int $file_size;
public ?int $file_size = null;

/** Optional. Thumbnail of the album cover to which the music file belongs */
public ?PhotoSize $thumb;
public ?PhotoSize $thumb = null;


/**
* @param string $file_id Identifier for this file, which can be used to download or reuse the file
* @param string $file_unique_id Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
* @param int $duration Duration of the audio in seconds as defined by sender
* @param string $performer Optional. Performer of the audio as defined by sender or by audio tags
* @param string $title Optional. Title of the audio as defined by sender or by audio tags
* @param string $file_name Optional. Original filename as defined by sender
* @param string $mime_type Optional. MIME type of the file as defined by sender
* @param int $file_size Optional. File size in bytes
* @param PhotoSize $thumb Optional. Thumbnail of the album cover to which the music file belongs
*/
public static function make(
string $file_id,
string $file_unique_id,
int $duration,
?string $performer = null,
?string $title = null,
?string $file_name = null,
?string $mime_type = null,
?int $file_size = null,
?PhotoSize $thumb = null
): static {
return new static([
'file_id' => $file_id,
'file_unique_id' => $file_unique_id,
'duration' => $duration,
'performer' => $performer,
'title' => $title,
'file_name' => $file_name,
'mime_type' => $mime_type,
'file_size' => $file_size,
'thumb' => $thumb,
]);
}
}
13 changes: 13 additions & 0 deletions src/Telegram/BotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@ class BotCommand extends \Tii\Telepath\Type

/** Description of the command; 1-256 characters. */
public string $description;


/**
* @param string $command Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
* @param string $description Description of the command; 1-256 characters.
*/
public static function make(string $command, string $description): static
{
return new static([
'command' => $command,
'description' => $description,
]);
}
}
11 changes: 11 additions & 0 deletions src/Telegram/BotCommandScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ class BotCommandScope extends \Tii\Telepath\Type
{
/** Scope type */
public string $type;


/**
* @param string $type Scope type
*/
public static function make(string $type): static
{
return new static([
'type' => $type,
]);
}
}
5 changes: 5 additions & 0 deletions src/Telegram/BotCommandScopeAllChatAdministrators.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
*/
class BotCommandScopeAllChatAdministrators extends BotCommandScope
{
public static function make(): static
{
return new static([
]);
}
}
5 changes: 5 additions & 0 deletions src/Telegram/BotCommandScopeAllGroupChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
*/
class BotCommandScopeAllGroupChats extends BotCommandScope
{
public static function make(): static
{
return new static([
]);
}
}
5 changes: 5 additions & 0 deletions src/Telegram/BotCommandScopeAllPrivateChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
*/
class BotCommandScopeAllPrivateChats extends BotCommandScope
{
public static function make(): static
{
return new static([
]);
}
}
11 changes: 11 additions & 0 deletions src/Telegram/BotCommandScopeChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ class BotCommandScopeChat extends BotCommandScope
{
/** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */
public int|string $chat_id;


/**
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*/
public static function make(int|string $chat_id): static
{
return new static([
'chat_id' => $chat_id,
]);
}
}
11 changes: 11 additions & 0 deletions src/Telegram/BotCommandScopeChatAdministrators.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ class BotCommandScopeChatAdministrators extends BotCommandScope
{
/** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */
public int|string $chat_id;


/**
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*/
public static function make(int|string $chat_id): static
{
return new static([
'chat_id' => $chat_id,
]);
}
}
13 changes: 13 additions & 0 deletions src/Telegram/BotCommandScopeChatMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@ class BotCommandScopeChatMember extends BotCommandScope

/** Unique identifier of the target user */
public int $user_id;


/**
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param int $user_id Unique identifier of the target user
*/
public static function make(int|string $chat_id, int $user_id): static
{
return new static([
'chat_id' => $chat_id,
'user_id' => $user_id,
]);
}
}
5 changes: 5 additions & 0 deletions src/Telegram/BotCommandScopeDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
*/
class BotCommandScopeDefault extends BotCommandScope
{
public static function make(): static
{
return new static([
]);
}
}
38 changes: 34 additions & 4 deletions src/Telegram/CallbackQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,47 @@ class CallbackQuery extends \Tii\Telepath\Type
public User $from;

/** 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 */
public ?Message $message;
public ?Message $message = null;

/** Optional. Identifier of the message sent via the bot in inline mode, that originated the query. */
public ?string $inline_message_id;
public ?string $inline_message_id = null;

/** Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. */
public string $chat_instance;

/** Optional. Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. */
public ?string $data;
public ?string $data = null;

/** Optional. Short name of a Game to be returned, serves as the unique identifier for the game */
public ?string $game_short_name;
public ?string $game_short_name = null;


/**
* @param string $id Unique identifier for this query
* @param User $from Sender
* @param Message $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
* @param string $inline_message_id Optional. Identifier of the message sent via the bot in inline mode, that originated the query.
* @param 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.
* @param string $data Optional. Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field.
* @param string $game_short_name Optional. Short name of a Game to be returned, serves as the unique identifier for the game
*/
public static function make(
string $id,
User $from,
?Message $message = null,
?string $inline_message_id = null,
string $chat_instance,
?string $data = null,
?string $game_short_name = null
): static {
return new static([
'id' => $id,
'from' => $from,
'message' => $message,
'inline_message_id' => $inline_message_id,
'chat_instance' => $chat_instance,
'data' => $data,
'game_short_name' => $game_short_name,
]);
}
}
Loading

0 comments on commit bd1c9e1

Please sign in to comment.