Skip to content

Added updates about member status changes in chats #1188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/Entities/ChatInviteLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Entities;

/**
* Class ChatInviteLink
*
* Represents an invite link for a chat
*
* @link https://core.telegram.org/bots/api#chatinvitelink
*
* @method string GetInviteLink() The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”
* @method User getCreator() Creator of the link
* @method bool getIsPrimary() True, if the link is primary
* @method bool getIsRevoked() True, if the link is revoked
* @method int getExpireDate() Optional. Point in time (Unix timestamp) when the link will expire or has been expired
* @method int getMemberLimit() Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
*/
class ChatInviteLink extends Entity
{
/**
* {@inheritdoc}
*/
protected function subEntities(): array
{
return [
'creator' => User::class
];
}
}
43 changes: 43 additions & 0 deletions src/Entities/ChatMemberUpdated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Entities;

/**
* Class ChatMemberUpdated
*
* Represents changes in the status of a chat member
*
* @link https://core.telegram.org/bots/api#chatmemberupdated
*
* @method Chat getChat() Chat the user belongs to
* @method User getUser() Performer of the action, which resulted in the change
* @method int getDate() Date the change was done in Unix time
* @method ChatMember getOldChatMember() Previous information about the chat member
* @method ChatMember getNewChatMember() New information about the chat member
* @method ChatInviteLink getInviteLink() Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
*/
class ChatMemberUpdated extends Entity
{
/**
* {@inheritdoc}
*/
protected function subEntities(): array
{
return [
'chat' => Chat::class,
'from' => User::class,
'old_chat_member' => ChatMember::class,
'new_chat_member' => ChatMember::class,
'invite_link' => ChatInviteLink::class,
];
}
}
4 changes: 4 additions & 0 deletions src/Entities/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* @method PreCheckoutQuery getPreCheckoutQuery() Optional. New incoming pre-checkout query. Contains full information about checkout
* @method Poll getPoll() Optional. New poll state. Bots receive only updates about polls, which are sent or stopped by the bot
* @method PollAnswer getPollAnswer() Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
* @method ChatMemberUpdated getMyChatMember() Optional. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.
* @method ChatMemberUpdated getChatMember() Optional. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates.
*/
class Update extends Entity
{
Expand All @@ -51,6 +53,8 @@ protected function subEntities(): array
'pre_checkout_query' => PreCheckoutQuery::class,
'poll' => Poll::class,
'poll_answer' => PollAnswer::class,
'my_chat_member' => ChatMemberUpdated::class,
'chat_member' => ChatMemberUpdated::class,
];
}

Expand Down