Skip to content

Commit

Permalink
fixes in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrzejkaNowicki committed Nov 21, 2024
1 parent 2a98e75 commit d397c6e
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 66 deletions.
8 changes: 4 additions & 4 deletions docs/11.quickstart/1.new-bot.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ Go to the [@BotFather](https://t.me/botfather) app on Telegram.

Send `/newbot`, to start creating a new Bot and setting its name and username.

<img src="/img/screenshots/new-bot.jpg" />
![](/docs/img/screenshots/new-bot.jpg)

Take note of the bot `token`.

<img src="/img/screenshots/new-bot-token.jpg" />
![](/docs/img/screenshots/new-bot-token.jpg)

### Join groups permission

To allow the bot to join Telegram groups, use the `/setjoingroups` command in @BotFather:

<img src="/img/screenshots/new-bot-joingroups.jpg" />
![](/docs/img/screenshots/new-bot-joingroups.jpg)

### Privacy
Now you need to choose how much the bot will be able to read from the chats. Send `/setprivacy` command to @BotFather, and select your bot privacy:

- **enable**: to handle only `/` commands handling
- **disable**: to allow the bot to read all messages sent to the chat

<img src="/img/screenshots/new-bot-setprivacy.jpg" />
![](/docs/img/screenshots/new-bot-setprivacy.jpg)
4 changes: 2 additions & 2 deletions docs/11.quickstart/2.register-new-bot.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ php artisan telegraph:new-bot
```
you will be guided through a bot creation wizard that will (optionally) allow you to add a new chat and setup a bot webhook as well

<img src="/img/screenshots/artisan-new-bot.jpg" />
![](/docs/img/screenshots/artisan-new-bot.jpg)

### programmatically

If you are implementing a custom bot creation logic, you can create a new bot using the `TelegraphBot` model:
If you are implementing a custom bot creation logic, you can create a new bot using the [`TelegraphBot`](/docs/14.models/1.telegraph-bot.md) model:

```php
$bot = TelegraphBot::create([
Expand Down
2 changes: 1 addition & 1 deletion docs/11.quickstart/3.setting-webhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ the `bot_id` argument is mandatory if you have created more than one bot

### programmatically

A webhook can be created programmatically for a bot by calling its `registerWebhook()` method
A webhook can be created programmatically for a bot by calling its [`registerWebhook()`](/docs/14.models/1.telegraph-bot.md#register-webhook) method

```php
/** @var TelegraphBot $bot */
Expand Down
4 changes: 2 additions & 2 deletions docs/11.quickstart/4.register-new-chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ navigation.title: 'Adding a chat'
Associating one or more chats to a bot, it is enabled to send messages to that chat and interacting with commands

> [!NOTE]
> To get the _chat_id_ issue the `/chatid` command inside the chat after having [set up a webhook](quickstart/setting-webhook) for your bot.
> To get the _chat_id_ issue the `/chatid` command inside the chat after having [set up a webhook](/docs/11.quickstart/3.setting-webhook.md) for your bot.

### through an artisan command
Expand All @@ -20,7 +20,7 @@ the bot_id argument is mandatory if you have created more than one bot

### programmatically

If you are implementing a custom bot creation logic, you can create a new chat using the `TelegraphChat` model:
If you are implementing a custom bot creation logic, you can create a new chat using the [`TelegraphChat`](/docs/14.models/2.telegraph-chat.md) model:

```php
/** @var TelegraphChat $chat */
Expand Down
2 changes: 1 addition & 1 deletion docs/11.quickstart/5.sending-a-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use DefStudio\Telegraph\Models\TelegraphChat;
$chat->html("<strong>Hello!</strong>\n\nI'm here!")->send();
```

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

as an alternative, messages can be formatted with markdown:

Expand Down
9 changes: 6 additions & 3 deletions docs/12.features/1.messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'Messages'
navigation.title: 'Messages'
---

Messages can be sent to a Telegram chat using a `TelegraphChat` model
Messages can be sent to a Telegram chat using a [`TelegraphChat`](/docs/14.models/2.telegraph-chat.md) model

```php
use DefStudio\Telegraph\Models\TelegraphChat;
Expand Down Expand Up @@ -48,6 +48,7 @@ $chat->message("ok!")->forceReply(placeholder: 'Enter your reply...')->send();
```

### forwardMessage
<a id='forward-message'></a>


Use this method to forward messages of any kind.
Expand All @@ -57,6 +58,7 @@ $chat->forwardMessage($fromChat,$messageId)->send();

```
### copyMessage
<a id='copy-message'></a>

Use this method to copy messages of any kind.
The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message.
Expand All @@ -82,6 +84,7 @@ $chat->message("late night message")->silent()->send();
```

### withoutPreview
<a id='without-preview'></a>

Disables link previews for links in this message

Expand All @@ -93,11 +96,11 @@ $chat->message("http://my-blog.dev")->withoutPreview()->send();

### Delete a message

The [`->deleteMessage()`](features/telegram-api-calls#deletemessage) Telegraph method allows to remove a message from a chat/group/channel.
The [`->deleteMessage()`](/docs/13.api/2.chats.md#delete-message) Telegraph method allows to remove a message from a chat/group/channel.

> [!WARNING]
> A message can be deleted if it was sent less than 48h ago and if it **was sent** by the bot or if the bot **has permission** to delete other users' messages.
### Delete multiple messages

The [`->deleteMessages()`](features/telegram-api-calls#deletemessages) Telegraph method allows to delete multiple messages from a chat/group/channel simultaneously. If some of the specified messages can't be found, they are skipped. Identifiers of 1-100 messages to delete.
The [`->deleteMessages()`](/docs/13.api/2.chats.md#delete-messages) Telegraph method allows to delete multiple messages from a chat/group/channel simultaneously. If some of the specified messages can't be found, they are skipped. Identifiers of 1-100 messages to delete.
2 changes: 1 addition & 1 deletion docs/12.features/2.telegraph-facade.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Telegraph::message('hello world')
```

> [!NOTE]
> Telegraph supports also sending emojis in messages and [keyboard](features/keyboards) button labels 🚀🚀🚀
> Telegraph supports also sending emojis in messages and [keyboard](/docs/12.features/3.keyboards.md) button labels 🚀🚀🚀
2 changes: 1 addition & 1 deletion docs/12.features/3.keyboards.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ navigation.title: 'Message Keyboards'

A keyboard can be added to a message in order to offer a set of options to the user:

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

## Attaching a keyboard

Expand Down
12 changes: 9 additions & 3 deletions docs/12.features/4.reply-keyboards.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ navigation.title: 'Reply Keyboards'

When sending a message, Telegram can be instructed to replace the standard phone keyboard with a custom one (see [here](https://core.telegram.org/bots#keyboards) for detailed info):

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

## Attaching a keyboard

Expand Down Expand Up @@ -148,7 +148,11 @@ $keyboard = ReplyKeyboard::make()

## Applying a keyboard to a specific user

A keyboard can be applied to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
A keyboard can be applied to specific users only.

Targets:
1) users that are *@mentioned* in the text of the Message object;
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.

Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard.

Expand Down Expand Up @@ -188,7 +192,9 @@ Telegraph::message('command received')

To remove the keyboard for a specific user, simply pass `true` parameter to the `removeReplyKeyboard` method.

Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
Targets:
1) users that are *@mentioned* in the text of the Message object;
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.

Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.

Expand Down
3 changes: 3 additions & 0 deletions docs/12.features/6.telegraph-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $response->json('path.to.json.data', 'default');
```

## telegraphOk
<a id='telegraph-ok'></a>

Returns true if the Telegram request is successful and contains `['ok' => true]` in its body

Expand All @@ -32,6 +33,7 @@ $response->telegraphOk(); //true
```

## telegraphError
<a id='telegraph-error'></a>

Returns true if the Telegram request is not successful or is successful but doesn't contain `['ok' => true]` in its body

Expand All @@ -42,6 +44,7 @@ $response->telegraphError(); //false
```

## telegraphMessageId
<a id='telegraph-message-id'></a>

Returns the ID of the message posted on the Telegraph chat (`null` if the request failed or no message was posted)

Expand Down
20 changes: 10 additions & 10 deletions docs/12.features/7.attachments.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Telegraph::message('hi')->inThread(THREAD_ID)->send();

Telegraph enforces Telegram default bot API limits for attachments.
When using a local Bot API Server, wider limits are allowed (see [docs](https://core.telegram.org/bots/api#using-a-local-bot-api-server) for reference)
and validation checks limits can be customized in [telegraph.php config](installation#Configuration) file (`attachments` section)
and validation checks limits can be customized in [telegraph.php config](/docs/2.installation.md#configuration) file (`attachments` section)


## Attachment types
Expand All @@ -42,7 +42,7 @@ Telegraph::photo($telegramFileId)->send();
```

> [!WARNING]
> Sent Photos can be edited with the [editMedia](features/telegram-api-calls#editMedia) call
> Sent Photos can be edited with the [editMedia](/docs/13.api/3.messages.md#edit-media) call

### Animations
Expand All @@ -56,7 +56,7 @@ Telegraph::animation($telegramFileId)->send();
```

> [!WARNING]
> Sent Animations can be edited with the [editMedia](features/telegram-api-calls#editMedia) call
> Sent Animations can be edited with the [editMedia](/docs/13.api/3.messages.md#edit-media) call

### Video
Expand All @@ -70,7 +70,7 @@ Telegraph::video($telegramFileId)->send();
```

> [!WARNING]
> Sent Videos can be edited with the [editMedia](features/telegram-api-calls#editMedia) call
> Sent Videos can be edited with the [editMedia](/docs/13.api/3.messages.md#edit-media) call

### Audio
Expand All @@ -84,7 +84,7 @@ Telegraph::audio($telegramFileId)->send();
```

> [!WARNING]
> Sent Audio messages can be edited with the [editMedia](features/telegram-api-calls#editMedia) call
> Sent Audio messages can be edited with the [editMedia](/docs/13.api/3.messages.md#edit-media) call

### Vocal Messages
Expand All @@ -109,7 +109,7 @@ Telegraph::document($telegramFileId)->send();
```

> [!WARNING]
> Sent Documents can be edited with the [editMedia](features/telegram-api-calls#editMedia) call
> Sent Documents can be edited with the [editMedia](/docs/13.api/3.messages.md#edit-media) call

### Location
Expand Down Expand Up @@ -152,7 +152,7 @@ Telegraph::sticker('https://my-repository/my_sticker.tgs')->send();
Telegraph::sticker($telegramFileId)->send();
```

Where `$telegramFileId` is file_id from telegram sticker set. File_id can obtain from Telegram Raw Bot (@RawDataBot). Just simply send a sticker to bot and you receive json data in answer. The required value is contained in 'message > sticker > file_id'.
Where `$telegramFileId` is file_id from telegram sticker set. File_id can obtain from Telegram Raw Bot (*@RawDataBot*). Just simply send a sticker to bot and you receive json data in answer. The required value is contained in 'message > sticker > file_id'.

## Options

Expand All @@ -167,7 +167,7 @@ Telegraph::document(Storage::path('my_document.pdf'))
```

> [!WARNING]
> Sent attachment captions can be edited with the [editCaption](features/telegram-api-calls#editCaption) call
> Sent attachment captions can be edited with the [editCaption](/docs/13.api/3.messages.md#edit-caption) call

### Markdown caption
Expand All @@ -179,7 +179,7 @@ Telegraph::document(Storage::path('my_document.pdf'))
```

> [!WARNING]
> Sent attachment captions can be edited with the [editCaption](features/telegram-api-calls#editCaption) call
> Sent attachment captions can be edited with the [editCaption](/docs/13.api/3.messages.md#edit-caption) call

### MarkdownV2 caption
Expand All @@ -191,7 +191,7 @@ Telegraph::document(Storage::path('my_document.pdf'))
```

> [!WARNING]
> Sent attachment captions can be edited with the [editCaption](features/telegram-api-calls#editCaption) call
> Sent attachment captions can be edited with the [editCaption](/docs/13.api/3.messages.md#edit-caption) call

### Without notification
Expand Down
14 changes: 13 additions & 1 deletion docs/13.api/1.bots.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ navigation.title: 'Bot Management'
---

## `botInfo()`
<a id="bot-info"></a>

retrieves Bot data from Telegram APIs

Expand All @@ -23,6 +24,7 @@ supports_inline_queries: false


## `botUpdates()`
<a id="bot-updates"></a>

retrieves the bot updates from Telegram APIs

Expand All @@ -31,10 +33,11 @@ Telegraph::bot($telegraphBot)->botUpdates()->send();
```

> [!WARNING]
> Manual updates polling is not available if a webhook is set up for the bot. Webhook should be remove first using its [unregisterWebhook](webhooks/deleting-webhooks) method
> Manual updates polling is not available if a webhook is set up for the bot. Webhook should be remove first using its [unregisterWebhook](/docs/14.models/1.telegraph-bot.md#unregister-webhook) method

### `Long Polling`
<a id="long-polling"></a>

In production environment, a timeout (in seconds) should be declared, in order to allow long polling:

Expand All @@ -45,6 +48,7 @@ Telegraph::bot($telegraphBot)->botUpdates(timeout: 60)->send();


## `registerBotCommands()`
<a id="register-bot-commands"></a>

register commands in Telegram Bot in order to display them to the user when the "/" key is pressed

Expand All @@ -56,6 +60,7 @@ Telegraph::registerBotCommands([
```

## `unregisterBotCommands()`
<a id="unregister-bot-commands"></a>

resets Telegram Bot registered commands

Expand All @@ -64,6 +69,7 @@ Telegraph::unregisterBotCommands()->send();
```

## `getRegisteredCommands()`
<a id="get-registered-commands"></a>

retrieve bot's registered commands.

Expand All @@ -75,6 +81,7 @@ $response->json('result');


## `registerWebhook()`
<a id="register-webhook"></a>

register a webhook for the active bot

Expand All @@ -89,6 +96,7 @@ you can use the method parameters to customize the webhook settings:
- `secretToken`: secret token to be sent in a `X-Telegram-Bot-Api-Secret-Token` header to verify the authenticity of the webhook

## `unregisterWebhook()`
<a id="unregister-webhook"></a>

unregister a webhook for the active bot

Expand All @@ -98,6 +106,7 @@ Telegraph::registerWebhook()->send();


## `getWebhookDebugInfo()`
<a id="get-webhook-debug-info"></a>

retrieves webhook debug data for the active bot

Expand All @@ -107,6 +116,7 @@ $response = Telegraph::getWebhookDebugInfo()->send();


## `getFileInfo`
<a id="get-file-info"></a>

Retrieve file info from ID

Expand All @@ -118,6 +128,7 @@ Telegraph::getFileInfo($fileId)->send();


## `store()`
<a id="store"></a>

Downloads a media file and stores it in the given path

Expand All @@ -133,6 +144,7 @@ Telegraph::store($photo, Storage::path('bot/images'), 'The Photo.jpg');

## `setBaseUrl()`
<a id="set-base-url"></a>

allows to override Telegram API url on a per-message basis:

Expand Down
Loading

0 comments on commit d397c6e

Please sign in to comment.