Skip to content

Commit ccb32d7

Browse files
authored
Merge pull request #1188 from massadm/chat_member
Added updates about member status changes in chats
2 parents d60d2ef + a13c847 commit ccb32d7

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

src/Entities/ChatInviteLink.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the TelegramBot package.
5+
*
6+
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Longman\TelegramBot\Entities;
13+
14+
/**
15+
* Class ChatInviteLink
16+
*
17+
* Represents an invite link for a chat
18+
*
19+
* @link https://core.telegram.org/bots/api#chatinvitelink
20+
*
21+
* @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 “…”
22+
* @method User getCreator() Creator of the link
23+
* @method bool getIsPrimary() True, if the link is primary
24+
* @method bool getIsRevoked() True, if the link is revoked
25+
* @method int getExpireDate() Optional. Point in time (Unix timestamp) when the link will expire or has been expired
26+
* @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
27+
*/
28+
class ChatInviteLink extends Entity
29+
{
30+
/**
31+
* {@inheritdoc}
32+
*/
33+
protected function subEntities(): array
34+
{
35+
return [
36+
'creator' => User::class
37+
];
38+
}
39+
}

src/Entities/ChatMemberUpdated.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the TelegramBot package.
5+
*
6+
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Longman\TelegramBot\Entities;
13+
14+
/**
15+
* Class ChatMemberUpdated
16+
*
17+
* Represents changes in the status of a chat member
18+
*
19+
* @link https://core.telegram.org/bots/api#chatmemberupdated
20+
*
21+
* @method Chat getChat() Chat the user belongs to
22+
* @method User getUser() Performer of the action, which resulted in the change
23+
* @method int getDate() Date the change was done in Unix time
24+
* @method ChatMember getOldChatMember() Previous information about the chat member
25+
* @method ChatMember getNewChatMember() New information about the chat member
26+
* @method ChatInviteLink getInviteLink() Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
27+
*/
28+
class ChatMemberUpdated extends Entity
29+
{
30+
/**
31+
* {@inheritdoc}
32+
*/
33+
protected function subEntities(): array
34+
{
35+
return [
36+
'chat' => Chat::class,
37+
'from' => User::class,
38+
'old_chat_member' => ChatMember::class,
39+
'new_chat_member' => ChatMember::class,
40+
'invite_link' => ChatInviteLink::class,
41+
];
42+
}
43+
}

src/Entities/Update.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* @method PreCheckoutQuery getPreCheckoutQuery() Optional. New incoming pre-checkout query. Contains full information about checkout
3232
* @method Poll getPoll() Optional. New poll state. Bots receive only updates about polls, which are sent or stopped by the bot
3333
* @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.
34+
* @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.
35+
* @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.
3436
*/
3537
class Update extends Entity
3638
{
@@ -51,6 +53,8 @@ protected function subEntities(): array
5153
'pre_checkout_query' => PreCheckoutQuery::class,
5254
'poll' => Poll::class,
5355
'poll_answer' => PollAnswer::class,
56+
'my_chat_member' => ChatMemberUpdated::class,
57+
'chat_member' => ChatMemberUpdated::class,
5458
];
5559
}
5660

0 commit comments

Comments
 (0)