Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrzejkaNowicki committed Nov 20, 2024
1 parent 9615f53 commit b2c00d5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
27 changes: 27 additions & 0 deletions docs/12.features/9.dto.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,30 @@ This is a DTO for outgoing data, wraps info about the Document result returned t
## `InlineQueryResultLocation`

This is a DTO for outgoing data, wraps info about the Location result returned to the user

## `ChatInviteLink`

represents an invite link for a chat.

- `->inviteLink()` the invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”
- `->creator()` an instance of [`User`](#user) represents a creator of the link
- `->createsJoinRequest()` *true*, if users joining the chat via the link need to be approved by chat administrators
- `->isPrimary()` *true*, if the link is primary
- `->isRevoked()` *true*, if the link is revoked
- `->name()` (optional) invite link name
- `->expireDate()` (optional) point in time (Unix timestamp) when the link will expire or has been expired
- `->memberLimit()` (optional) The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
- `->pendingJoinRequestsCount()` (optional) number of pending join requests created using this link
- `->subscriptionPeriod()` (optional) the number of seconds the subscription will be active for before the next payment
- `->subscriptionPrice()` (optional) the amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link

## `ChatJoinRequest`

represents a join request sent to a chat.

- `->chat()` an instance of [`Chat`](#chat) to which the request was sent
- `->from()` an instance of [`User`](#user) that sent the join request
- `->userChatId()` 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 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user.
- `->date()` date the request was sent in Unix time
- `->bio()` (optional) bio of the user
- `->inviteLink()` (optional) an instance of [`ChatInviteLink`](#chat-invite-link) that was used by the user to send the join request
24 changes: 23 additions & 1 deletion docs/15.webhooks/4.webhook-request-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,23 @@ Different kind of result can be sent through the handler:

## Member activities

Telegraph bots can listen for members join/leave activity in chats where they are registered and handle them by overriding `handleChatMemberJoined` and `handleChatMemberLeaved` methods:
Telegraph bots can listen for members join/leave activity in chats where they are registered and handle them by overriding `handleChatJoinRequest`, `handleChatMemberJoined` and `handleChatMemberLeaved` methods:

### Member has sent a request to join

```php
class CustomWebhookHandler extends WebhookHandler
{
protected function handleChatJoinRequest(ChatJoinRequest $chatJoinRequest): void
{
if (someCondition()) {
$this->chat->approveJoinRequest($chatJoinRequest->from()->id());
} else {
$this->chat->declineJoinRequest($chatJoinRequest->from()->id());
}
}
}
```

### Member joined

Expand All @@ -253,3 +269,9 @@ class CustomWebhookHandler extends WebhookHandler
}
}
```

Used DTOs:

- User ([`DefStudio\Telegraph\DTO\User`](../12.features/9.dto.md#user))
- Chat ([`DefStudio\Telegraph\DTO\Chat`](../12.features/9.dto.md#chat))
- ChatJoinRequest ([`DefStudio\Telegraph\DTO\ChatJoinRequest`](../12.features/9.dto.md#chatjoinrequest))

0 comments on commit b2c00d5

Please sign in to comment.