1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-29 22:27:42 +02:00
Files
OpenIntegrations/docs/en/md/Telegram/Data-sending/Form-keyboard-from-button-array.mdx

89 lines
2.2 KiB
Plaintext
Raw Normal View History

2024-10-15 10:50:56 +03:00
---
2025-01-16 21:22:31 +03:00
sidebar_position: 16
2025-05-05 11:15:20 +03:00
description: Generate keyboard from array of buttons and other functions to work with Telegram in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Telegram]
2024-10-15 10:16:04 +03:00
---
2024-10-15 10:50:56 +03:00
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
2024-10-15 10:16:04 +03:00
# Generate keyboard from array of buttons
Generates a simple JSON keyboard from an array of buttons for a message or bottom panel
`Function FormKeyboardFromButtonArray(Val ButtonArray, Val UnderMessage = False, Val OneByOne = True) Export`
2024-10-15 15:15:47 +03:00
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| ButtonArray | --buttons | Array of String | ✔ | Array of buttons |
| UnderMessage | --under | Boolean | ✖ | Keyboard under the message or on the bottom panel |
| OneByOne | --column | Boolean | ✖ | True > buttons are displayed in a column, False > in a row |
2024-10-15 10:16:04 +03:00
Returns: String - Keyboard JSON
<br/>
:::tip
2024-11-21 13:27:18 +03:00
About keyboards in the API documentation: [InlineKeyboardMarkup](https://core.telegram.org/bots/api#inlinekeyboardmarkup)
2024-10-15 10:16:04 +03:00
:::
<br/>
2024-10-15 21:15:56 +03:00
```bsl title="1C:Enterprise/OneScript code example"
2024-10-15 10:16:04 +03:00
ButtonArray = New Array;
ButtonArray.Add("Button1");
ButtonArray.Add("Button2");
ButtonArray.Add("Button3");
Result = OPI_Telegram.FormKeyboardFromButtonArray(ButtonArray);
```
2024-10-20 22:36:03 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint telegram FormKeyboardFromButtonArray \
2025-09-16 09:07:33 +03:00
--buttons "['Button1','Button2','Button3']" \
--under true
2024-10-20 22:36:03 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint telegram FormKeyboardFromButtonArray ^
2025-09-16 09:07:33 +03:00
--buttons "['Button1','Button2','Button3']" ^
--under true
2024-10-20 22:36:03 +03:00
```
</TabItem>
</Tabs>
2024-10-15 10:16:04 +03:00
```json title="Result"
2025-09-16 09:07:33 +03:00
{
"keyboard": [
[
{
"text": "Button1",
"callback_data": "Button1"
}
],
[
{
"text": "Button2",
"callback_data": "Button2"
}
],
[
{
"text": "Button3",
"callback_data": "Button3"
}
]
],
"resize_keyboard": true
}
2024-10-15 10:16:04 +03:00
```