Skip to content

Commit

Permalink
Update code to reflect latest changes to the API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TiiFuchs committed Feb 3, 2023
1 parent 5bbd731 commit aaa5d68
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 44 deletions.
12 changes: 9 additions & 3 deletions src/Layers/Generated.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,13 +804,15 @@ public function unbanChatMember(int|string $chat_id, int $user_id, ?bool $only_i
* @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
* @param ChatPermissions $permissions A JSON-serialized object for new user permissions
* @param bool $use_independent_chat_permissions Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
* @param int $until_date Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
* @throws \Telepath\Exceptions\TelegramException
*/
public function restrictChatMember(
int|string $chat_id,
int $user_id,
ChatPermissions $permissions,
?bool $use_independent_chat_permissions = null,
?int $until_date = null,
): bool {
return $this->raw('restrictChatMember', func_get_args());
Expand Down Expand Up @@ -896,10 +898,14 @@ public function unbanChatSenderChat(int|string $chat_id, int $sender_chat_id): b
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param ChatPermissions $permissions A JSON-serialized object for new default chat permissions
* @param bool $use_independent_chat_permissions Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
* @throws \Telepath\Exceptions\TelegramException
*/
public function setChatPermissions(int|string $chat_id, ChatPermissions $permissions): bool
{
public function setChatPermissions(
int|string $chat_id,
ChatPermissions $permissions,
?bool $use_independent_chat_permissions = null,
): bool {
return $this->raw('setChatPermissions', func_get_args());
}

Expand Down Expand Up @@ -1121,7 +1127,7 @@ public function getChatMemberCount(int|string $chat_id): int
}

/**
* Use this method to get information about a member of a chat. The method is guaranteed to work for other users, only if the bot is an administrator in the chat. Returns a ChatMember object on success.
* Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a ChatMember object on success.
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @param int $user_id Unique identifier of the target user
Expand Down
6 changes: 6 additions & 0 deletions src/Telegram/ChatJoinRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class ChatJoinRequest extends Type
/** User that sent the join request */
public User $from;

/** Identifier of a private chat with the user who sent the join request. 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. The bot can use this identifier for 24 hours to send messages until the join request is processed, assuming no other administrator contacted the user. */
public int $user_chat_id;

/** Date the request was sent in Unix time */
public int $date;

Expand All @@ -31,20 +34,23 @@ class ChatJoinRequest extends Type
/**
* @param Chat $chat Chat to which the request was sent
* @param User $from User that sent the join request
* @param int $user_chat_id Identifier of a private chat with the user who sent the join request. 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. The bot can use this identifier for 24 hours to send messages until the join request is processed, assuming no other administrator contacted the user.
* @param int $date Date the request was sent in Unix time
* @param string $bio Optional. Bio of the user.
* @param ChatInviteLink $invite_link Optional. Chat invite link that was used by the user to send the join request
*/
public static function make(
Chat $chat,
User $from,
int $user_chat_id,
int $date,
?string $bio = null,
?ChatInviteLink $invite_link = null,
): static {
return new static([
'chat' => $chat,
'from' => $from,
'user_chat_id' => $user_chat_id,
'date' => $date,
'bio' => $bio,
'invite_link' => $invite_link,
Expand Down
84 changes: 57 additions & 27 deletions src/Telegram/ChatMemberRestricted.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,26 @@ class ChatMemberRestricted extends ChatMember
/** True, if the user is a member of the chat at the moment of the request */
public bool $is_member;

/** True, if the user is allowed to change the chat title, photo and other settings */
public bool $can_change_info;
/** True, if the user is allowed to send text messages, contacts, invoices, locations and venues */
public bool $can_send_messages;

/** True, if the user is allowed to invite new users to the chat */
public bool $can_invite_users;
/** True, if the user is allowed to send audios */
public bool $can_send_audios;

/** True, if the user is allowed to pin messages */
public bool $can_pin_messages;
/** True, if the user is allowed to send documents */
public bool $can_send_documents;

/** True, if the user is allowed to create forum topics */
public bool $can_manage_topics;
/** True, if the user is allowed to send photos */
public bool $can_send_photos;

/** True, if the user is allowed to send text messages, contacts, locations and venues */
public bool $can_send_messages;
/** True, if the user is allowed to send videos */
public bool $can_send_videos;

/** True, if the user is allowed to send video notes */
public bool $can_send_video_notes;

/** True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes */
public bool $can_send_media_messages;
/** True, if the user is allowed to send voice notes */
public bool $can_send_voice_notes;

/** True, if the user is allowed to send polls */
public bool $can_send_polls;
Expand All @@ -44,49 +47,76 @@ class ChatMemberRestricted extends ChatMember
/** True, if the user is allowed to add web page previews to their messages */
public bool $can_add_web_page_previews;

/** True, if the user is allowed to change the chat title, photo and other settings */
public bool $can_change_info;

/** True, if the user is allowed to invite new users to the chat */
public bool $can_invite_users;

/** True, if the user is allowed to pin messages */
public bool $can_pin_messages;

/** True, if the user is allowed to create forum topics */
public bool $can_manage_topics;

/** Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever */
public int $until_date;

/**
* @param User $user Information about the user
* @param bool $is_member True, if the user is a member of the chat at the moment of the request
* @param bool $can_send_messages True, if the user is allowed to send text messages, contacts, invoices, locations and venues
* @param bool $can_send_audios True, if the user is allowed to send audios
* @param bool $can_send_documents True, if the user is allowed to send documents
* @param bool $can_send_photos True, if the user is allowed to send photos
* @param bool $can_send_videos True, if the user is allowed to send videos
* @param bool $can_send_video_notes True, if the user is allowed to send video notes
* @param bool $can_send_voice_notes True, if the user is allowed to send voice notes
* @param bool $can_send_polls True, if the user is allowed to send polls
* @param bool $can_send_other_messages True, if the user is allowed to send animations, games, stickers and use inline bots
* @param bool $can_add_web_page_previews True, if the user is allowed to add web page previews to their messages
* @param bool $can_change_info True, if the user is allowed to change the chat title, photo and other settings
* @param bool $can_invite_users True, if the user is allowed to invite new users to the chat
* @param bool $can_pin_messages True, if the user is allowed to pin messages
* @param bool $can_manage_topics True, if the user is allowed to create forum topics
* @param bool $can_send_messages True, if the user is allowed to send text messages, contacts, locations and venues
* @param bool $can_send_media_messages True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
* @param bool $can_send_polls True, if the user is allowed to send polls
* @param bool $can_send_other_messages True, if the user is allowed to send animations, games, stickers and use inline bots
* @param bool $can_add_web_page_previews True, if the user is allowed to add web page previews to their messages
* @param int $until_date Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever
*/
public static function make(
User $user,
bool $is_member,
bool $can_change_info,
bool $can_invite_users,
bool $can_pin_messages,
bool $can_manage_topics,
bool $can_send_messages,
bool $can_send_media_messages,
bool $can_send_audios,
bool $can_send_documents,
bool $can_send_photos,
bool $can_send_videos,
bool $can_send_video_notes,
bool $can_send_voice_notes,
bool $can_send_polls,
bool $can_send_other_messages,
bool $can_add_web_page_previews,
bool $can_change_info,
bool $can_invite_users,
bool $can_pin_messages,
bool $can_manage_topics,
int $until_date,
): static {
return new static([
'user' => $user,
'is_member' => $is_member,
'can_change_info' => $can_change_info,
'can_invite_users' => $can_invite_users,
'can_pin_messages' => $can_pin_messages,
'can_manage_topics' => $can_manage_topics,
'can_send_messages' => $can_send_messages,
'can_send_media_messages' => $can_send_media_messages,
'can_send_audios' => $can_send_audios,
'can_send_documents' => $can_send_documents,
'can_send_photos' => $can_send_photos,
'can_send_videos' => $can_send_videos,
'can_send_video_notes' => $can_send_video_notes,
'can_send_voice_notes' => $can_send_voice_notes,
'can_send_polls' => $can_send_polls,
'can_send_other_messages' => $can_send_other_messages,
'can_add_web_page_previews' => $can_add_web_page_previews,
'can_change_info' => $can_change_info,
'can_invite_users' => $can_invite_users,
'can_pin_messages' => $can_pin_messages,
'can_manage_topics' => $can_manage_topics,
'until_date' => $until_date,
]);
}
Expand Down
56 changes: 43 additions & 13 deletions src/Telegram/ChatPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,34 @@
*/
class ChatPermissions extends Type
{
/** Optional. True, if the user is allowed to send text messages, contacts, locations and venues */
/** Optional. True, if the user is allowed to send text messages, contacts, invoices, locations and venues */
public ?bool $can_send_messages = null;

/** Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages */
public ?bool $can_send_media_messages = null;
/** Optional. True, if the user is allowed to send audios */
public ?bool $can_send_audios = null;

/** Optional. True, if the user is allowed to send polls, implies can_send_messages */
/** Optional. True, if the user is allowed to send documents */
public ?bool $can_send_documents = null;

/** Optional. True, if the user is allowed to send photos */
public ?bool $can_send_photos = null;

/** Optional. True, if the user is allowed to send videos */
public ?bool $can_send_videos = null;

/** Optional. True, if the user is allowed to send video notes */
public ?bool $can_send_video_notes = null;

/** Optional. True, if the user is allowed to send voice notes */
public ?bool $can_send_voice_notes = null;

/** Optional. True, if the user is allowed to send polls */
public ?bool $can_send_polls = null;

/** Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages */
/** Optional. True, if the user is allowed to send animations, games, stickers and use inline bots */
public ?bool $can_send_other_messages = null;

/** Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages */
/** Optional. True, if the user is allowed to add web page previews to their messages */
public ?bool $can_add_web_page_previews = null;

/** Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups */
Expand All @@ -41,19 +56,29 @@ class ChatPermissions extends Type
public ?bool $can_manage_topics = null;

/**
* @param bool $can_send_messages Optional. True, if the user is allowed to send text messages, contacts, locations and venues
* @param bool $can_send_media_messages Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
* @param bool $can_send_polls Optional. True, if the user is allowed to send polls, implies can_send_messages
* @param bool $can_send_other_messages Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages
* @param bool $can_add_web_page_previews Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages
* @param bool $can_send_messages Optional. True, if the user is allowed to send text messages, contacts, invoices, locations and venues
* @param bool $can_send_audios Optional. True, if the user is allowed to send audios
* @param bool $can_send_documents Optional. True, if the user is allowed to send documents
* @param bool $can_send_photos Optional. True, if the user is allowed to send photos
* @param bool $can_send_videos Optional. True, if the user is allowed to send videos
* @param bool $can_send_video_notes Optional. True, if the user is allowed to send video notes
* @param bool $can_send_voice_notes Optional. True, if the user is allowed to send voice notes
* @param bool $can_send_polls Optional. True, if the user is allowed to send polls
* @param bool $can_send_other_messages Optional. True, if the user is allowed to send animations, games, stickers and use inline bots
* @param bool $can_add_web_page_previews Optional. True, if the user is allowed to add web page previews to their messages
* @param bool $can_change_info Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups
* @param bool $can_invite_users Optional. True, if the user is allowed to invite new users to the chat
* @param bool $can_pin_messages Optional. True, if the user is allowed to pin messages. Ignored in public supergroups
* @param bool $can_manage_topics Optional. True, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messages
*/
public static function make(
?bool $can_send_messages = null,
?bool $can_send_media_messages = null,
?bool $can_send_audios = null,
?bool $can_send_documents = null,
?bool $can_send_photos = null,
?bool $can_send_videos = null,
?bool $can_send_video_notes = null,
?bool $can_send_voice_notes = null,
?bool $can_send_polls = null,
?bool $can_send_other_messages = null,
?bool $can_add_web_page_previews = null,
Expand All @@ -64,7 +89,12 @@ public static function make(
): static {
return new static([
'can_send_messages' => $can_send_messages,
'can_send_media_messages' => $can_send_media_messages,
'can_send_audios' => $can_send_audios,
'can_send_documents' => $can_send_documents,
'can_send_photos' => $can_send_photos,
'can_send_videos' => $can_send_videos,
'can_send_video_notes' => $can_send_video_notes,
'can_send_voice_notes' => $can_send_voice_notes,
'can_send_polls' => $can_send_polls,
'can_send_other_messages' => $can_send_other_messages,
'can_add_web_page_previews' => $can_add_web_page_previews,
Expand Down
33 changes: 33 additions & 0 deletions src/Telegram/ChatShared.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* This object contains information about the chat whose identifier was shared with the bot using a KeyboardButtonRequestChat button.
*/
class ChatShared extends Type
{
/** Identifier of the request */
public int $request_id;

/** Identifier of the shared chat. 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. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means. */
public int $chat_id;

/**
* @param int $request_id Identifier of the request
* @param int $chat_id Identifier of the shared chat. 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. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
*/
public static function make(int $request_id, int $chat_id): static
{
return new static([
'request_id' => $request_id,
'chat_id' => $chat_id,
]);
}
}
Loading

0 comments on commit aaa5d68

Please sign in to comment.