Skip to content

Commit

Permalink
add tags to DTO and fix links in webhook-request-types
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrzejkaNowicki committed Nov 21, 2024
1 parent 267a5e7 commit 2a98e75
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
23 changes: 20 additions & 3 deletions docs/12.features/9.dto.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: 'Incoming Data'
Data obtained from manual polling or webhooks is available through a set of DTO, under the `DefStudio\Telegraph\DTO\` namespace:

## `TelegramUpdate`
<a id="telegram-update"></a>

contains incoming data (a message or a callback query)

Expand Down Expand Up @@ -47,12 +48,13 @@ contains incoming data (a message or a callback query)
- `->newChatMembers()` a collection of [`User`](#user) holding the list of users that joined the group/supergroup
- `->leftChatMember()` (optional) an instance of [`User`](#user) holding data about the user that left the group/supergroup
- `->webAppData()` (optional) incoming data from sendData method of telegram WebApp
- `->writeAccessAllowed()` (optional) an instance of [`WriteAccessAllowed`](#WriteAccessAllowed) holding data about the contained write access allowed data
- `->writeAccessAllowed()` (optional) an instance of [`WriteAccessAllowed`](#write-access-allowed) holding data about the contained write access allowed data




## `CallbackQuery`
<a id="callback-query"></a>

- `->id()` incoming _callback_query_id_
- `->from()` (optional) an instance of the [`User`](#user) that triggered the callback query
Expand All @@ -65,11 +67,12 @@ contains incoming data (a message or a callback query)
- `->chat()` an instance of [`Chat`](#chat) holding data about the chat to which the message belongs to
- `->actorChat()` (optional) an instance of [`Chat`](#chat) holding data about the chat to which the chat on behalf of which the reaction was changed, if the user is anonymous
- `->from()` (optional) an instance of [`User`](#user) holding data about the message's sender
- `->oldReaction()` a collection of [`ReactionType`](#reactiontype) holding data about the contained reaction type resolutions
- `->newReaction()` a collection of [`ReactionType`](#reactiontype) holding data about the contained reaction type resolutions
- `->oldReaction()` a collection of [`ReactionType`](#reaction-type) holding data about the contained reaction type resolutions
- `->newReaction()` a collection of [`ReactionType`](#reaction-type) holding data about the contained reaction type resolutions
- `->date()` a `CarbonInterface` holding the message sent

## `ReactionType`
<a id="reaction-type"></a>

- `->type()` type of the reaction
- `->emoji()` reaction emoji
Expand Down Expand Up @@ -177,6 +180,7 @@ contains incoming data (a message or a callback query)
- `->customEmojiId()` (optional) for “custom_emoji” only, unique identifier of the custom emoji

## `WriteAccessAllowed`
<a id="write-access-allowed"></a>

- `->fromRequest()` true, if the access was granted after the user accepted an explicit request from a Web App sent by the method [requestWriteAccess](https://core.telegram.org/bots/webapps#initializing-mini-apps)
- `->fromWebApp()` a helper method that returns true if the access was granted when the Web App was launched from a link
Expand All @@ -186,6 +190,7 @@ contains incoming data (a message or a callback query)


## `InlineQuery`
<a id="inline-query"></a>

- `->id()` inline query _id_
- `->query()` the query typed by the user after the bot's name
Expand All @@ -195,46 +200,57 @@ contains incoming data (a message or a callback query)
- `->location()` (optional) an instance of [`Location`](#photo) containing sender location, only for bots that request user location.

## `InlineQueryResultGif`
<a id="inline-query-result-gif"></a>

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

## `InlineQueryResultPhoto`
<a id="inline-query-result-photo"></a>

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

## `InlineQueryResultContact`
<a id="inline-query-result-contact"></a>

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

## `InlineQueryResultArticle`
<a id="inline-query-result-article"></a>

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

## `InlineQueryResultMpeg4Gif`
<a id="inline-query-result-mpeg4gif"></a>

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

## `InlineQueryResultVideo`
<a id="inline-query-result-video"></a>

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

## `InlineQueryResultAudio`
<a id="inline-query-result-audio"></a>

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

## `InlineQueryResultVoice`
<a id="inline-query-result-voice"></a>

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

## `InlineQueryResultDocument`
<a id="inline-query-result-document"></a>

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

## `InlineQueryResultLocation`
<a id="inline-query-result-location"></a>

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

## `ChatInviteLink`
<a id="chat-invite-link"></a>

represents an invite link for a chat.

Expand All @@ -251,6 +267,7 @@ represents an invite link for a chat.
- `->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`
<a id="chat-join-request"></a>

represents a join request sent to a chat.

Expand Down
38 changes: 19 additions & 19 deletions docs/15.webhooks/4.webhook-request-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CustomWebhookHandler extends WebhookHandler
```

> [!WARNING]
> A bot can read non-command/queries messages only if its `privacy mode` is disabled. To change a bot privacy settings see [this guide](quickstart/new-bot#privacy)
> A bot can read non-command/queries messages only if its `privacy mode` is disabled. To change a bot privacy settings see [this guide](/docs/11.quickstart/1.new-bot.md#privacy)

You can also handle any content of Telegram, like: Contact, Photo, Voice and etc...
Expand Down Expand Up @@ -65,7 +65,7 @@ class CustomWebhookHandler extends WebhookHandler

> [!WARNING]
> By default, Telegram does not report events related to reactions to messages.
> To interact with reactions, [specify](config/telegraph.php) in the settings all
> To interact with reactions, [specify](/config//telegraph.php) in the settings all
> [types of messages](https://core.telegram.org/bots/api#update) for which you want to catch events.
## Chat Commands
Expand Down Expand Up @@ -100,7 +100,7 @@ class CustomWebhookHandler extends WebhookHandler
}
```

The full chat message data can be retrieved through the [`DefStudio\Telegraph\DTO\Message`](features/dto#message) DTO:
The full chat message data can be retrieved through the [`DefStudio\Telegraph\DTO\Message`](/docs/12.features/9.dto.md#message) DTO:

```php
class CustomWebhookHandler extends WebhookHandler
Expand Down Expand Up @@ -140,7 +140,7 @@ class MyWebhookHandler extends WebhookHandler

Bots messages may ship with keyboard of buttons that trigger actions when pressed:

<img src=/img/screenshots/keyboard-example.png" />
![](/docs/img/screenshots/keyboard-example.png)

when pressed, a new call will be forwarded to the webhook with the following payload

Expand All @@ -164,7 +164,7 @@ class CustomWebhookHandler extends WebhookHandler
}
```

The full callback query data can be retrieved through the [`DefStudio\Telegraph\DTO\CallbackQuery`](features/dto#callback-query) DTO
The full callback query data can be retrieved through the [`DefStudio\Telegraph\DTO\CallbackQuery`](/docs/12.features/9.dto.md#callback-query) DTO

```php
class CustomWebhookHandler extends WebhookHandler
Expand All @@ -182,7 +182,7 @@ class CustomWebhookHandler extends WebhookHandler

## Inline queries

Users can interact with a bot through inline queries calling it by typing its name followed by the query. The query is sent to the webhook (or can be [manually polled](webhooks/manual-polling)) wrapped in a [`DefStudio\Telegraph\DTO\InlineQuery`](features/dto#inline-query). For more information see [inline bot page](https://core.telegram.org/bots/inline) and [the official api documentation](https://core.telegram.org/bots/api#inline-mode)
Users can interact with a bot through inline queries calling it by typing its name followed by the query. The query is sent to the webhook (or can be [manually polled](/docs/15.webhooks/8.manual-polling.md)) wrapped in a [`DefStudio\Telegraph\DTO\InlineQuery`](/docs/12.features/9.dto.md#inline-query). For more information see [inline bot page](https://core.telegram.org/bots/inline) and [the official api documentation](https://core.telegram.org/bots/api#inline-mode)

<alert type="alert">Inline queries should be enabled inside bot configuration (see [here](https://core.telegram.org/bots/inline) for more info)</alert>

Expand Down Expand Up @@ -212,18 +212,18 @@ class CustomWebhookHandler extends WebhookHandler

Different kind of result can be sent through the handler:

- Article ([`DefStudio\Telegraph\DTO\InlineQueryResultArticle`](features/dto#inline-query-result-article))
- Audio ([`DefStudio\Telegraph\DTO\InlineQueryResultAudio`](features/dto#inline-query-result-audio))
- Contact ([`DefStudio\Telegraph\DTO\InlineQueryResultContact`](features/dto#inline-query-result-contact))
- Article ([`DefStudio\Telegraph\DTO\InlineQueryResultArticle`](/docs/12.features/9.dto.md#inline-query-result-article))
- Audio ([`DefStudio\Telegraph\DTO\InlineQueryResultAudio`](/docs/12.features/9.dto.md#inline-query-result-audio))
- Contact ([`DefStudio\Telegraph\DTO\InlineQueryResultContact`](/docs/12.features/9.dto.md#inline-query-result-contact))
- Game (coming soon)
- Document ([`DefStudio\Telegraph\DTO\InlineQueryResultDocument`](features/dto#inline-query-result-document))
- Gif ([`DefStudio\Telegraph\DTO\InlineQueryResultGif`](features/dto#inline-query-result-gif))
- Location ([`DefStudio\Telegraph\DTO\InlineQueryResultLocation`](features/dto#inline-query-result-location))
- Mpeg4Gif ([`DefStudio\Telegraph\DTO\InlineQueryResultMpeg4Gif`](features/dto#inline-query-result-Mpeg4Gif))
- Photo([`DefStudio\Telegraph\DTO\InlineQueryResultPhoto`](features/dto#inline-query-result-photo))
- Document ([`DefStudio\Telegraph\DTO\InlineQueryResultDocument`](/docs/12.features/9.dto.md#inline-query-result-document))
- Gif ([`DefStudio\Telegraph\DTO\InlineQueryResultGif`](/docs/12.features/9.dto.md#inline-query-result-gif))
- Location ([`DefStudio\Telegraph\DTO\InlineQueryResultLocation`](/docs/12.features/9.dto.md#inline-query-result-location))
- Mpeg4Gif ([`DefStudio\Telegraph\DTO\InlineQueryResultMpeg4Gif`](/docs/12.features/9.dto.md#inline-query-result-Mpeg4Gif))
- Photo([`DefStudio\Telegraph\DTO\InlineQueryResultPhoto`](/docs/12.features/9.dto.md#inline-query-result-photo))
- Venue (coming soon)
- Video ([`DefStudio\Telegraph\DTO\InlineQueryResultVideo`](features/dto#inline-query-result-video))
- Voice ([`DefStudio\Telegraph\DTO\InlineQueryResultVoice`](features/dto#inline-query-result-voice))
- Video ([`DefStudio\Telegraph\DTO\InlineQueryResultVideo`](/docs/12.features/9.dto.md#inline-query-result-video))
- Voice ([`DefStudio\Telegraph\DTO\InlineQueryResultVoice`](/docs/12.features/9.dto.md#inline-query-result-voice))


## Member activities
Expand Down Expand Up @@ -272,6 +272,6 @@ 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))
- User ([`DefStudio\Telegraph\DTO\User`](/docs/12.features/9.dto.md#user))
- Chat ([`DefStudio\Telegraph\DTO\Chat`](/docs/12.features/9.dto.md#chat))
- ChatJoinRequest ([`DefStudio\Telegraph\DTO\ChatJoinRequest`](/docs/12.features/9.dto.md#chatjoinrequest))

0 comments on commit 2a98e75

Please sign in to comment.