Skip to content

Commit

Permalink
Merge pull request #617 from ivankuraev/main
Browse files Browse the repository at this point in the history
Added chatAdministrators() method
  • Loading branch information
fabio-ivona authored Aug 26, 2024
2 parents 9af9435 + dfe4e77 commit 847276d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/13.api/2.chats.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ retrieves a Chat member
Telegraph::chatMember($userId)->send();
```

## `chatAdministrators()`

retrieves a list of administrators in a chat, which aren't bots

```php
Telegraph::chatAdministrators()->send();
```

## `userProfilePhotos()`

retrieves the User's profile photos
Expand Down
10 changes: 10 additions & 0 deletions src/Concerns/HasBotsAndChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@ public function chatMember(string $userId): Telegraph
return $telegraph;
}

public function chatAdministrators(): Telegraph
{
$telegraph = clone $this;

$telegraph->endpoint = self::ENDPOINT_GET_CHAT_ADMINISTRATORS;
$telegraph->data['chat_id'] = $telegraph->getChatId();

return $telegraph;
}

/**
* @param array<int|string, string|bool> $permissions
*/
Expand Down
1 change: 1 addition & 0 deletions src/Telegraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class Telegraph
public const ENDPOINT_GET_CHAT_INFO = 'getChat';
public const ENDPOINT_GET_CHAT_MEMBER_COUNT = 'getChatMemberCount';
public const ENDPOINT_GET_CHAT_MEMBER = 'getChatMember';
public const ENDPOINT_GET_CHAT_ADMINISTRATORS = 'getChatAdministrators';
public const ENDPOINT_SET_CHAT_PERMISSIONS = 'setChatPermissions';
public const ENDPOINT_BAN_CHAT_MEMBER = 'banChatMember';
public const ENDPOINT_UNBAN_CHAT_MEMBER = 'unbanChatMember';
Expand Down
6 changes: 6 additions & 0 deletions tests/Unit/Concerns/HasBotsAndChatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@
})->toMatchTelegramSnapshot();
});

it('can retrieve a chat administrators', function () {
expect(function (\DefStudio\Telegraph\Telegraph $telegraph) {
return $telegraph->chat(make_chat())->chatAdministrators();
})->toMatchTelegramSnapshot();
});

it('can generate a chat primary invite link', function () {
expect(function (\DefStudio\Telegraph\Telegraph $telegraph) {
return $telegraph->chat(make_chat())->generateChatPrimaryInviteLink();
Expand Down

0 comments on commit 847276d

Please sign in to comment.