1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-04-04 22:14:37 +02:00
OpenIntegrations/docs/en/md/Telegram/Data-sending/Form-keyboard-from-button-array.mdx
Vitaly the Alpaca (bot) 003878a3cb Main build (Jenkins)
2025-01-16 21:22:31 +03:00

64 lines
1.9 KiB
Plaintext
Vendored

---
sidebar_position: 16
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# 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`
| 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 |
Returns: String - Keyboard JSON
<br/>
:::tip
About keyboards in the API documentation: [InlineKeyboardMarkup](https://core.telegram.org/bots/api#inlinekeyboardmarkup)
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
ButtonArray = New Array;
ButtonArray.Add("Button1");
ButtonArray.Add("Button2");
ButtonArray.Add("Button3");
Result = OPI_Telegram.FormKeyboardFromButtonArray(ButtonArray);
```
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint telegram FormKeyboardFromButtonArray \
--buttons "['Button1','Button2','Button3']"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint telegram FormKeyboardFromButtonArray ^
--buttons "['Button1','Button2','Button3']"
```
</TabItem>
</Tabs>
```json title="Result"
"{\r\n \"keyboard\": [\r\n [\r\n {\r\n \"text\": \"Button1\",\r\n \"callback_data\": \"Button1\"\r\n }\r\n ],\r\n [\r\n {\r\n \"text\": \"Button2\",\r\n \"callback_data\": \"Button2\"\r\n }\r\n ],\r\n [\r\n {\r\n \"text\": \"Button3\",\r\n \"callback_data\": \"Button3\"\r\n }\r\n ]\r\n ],\r\n \"resize_keyboard\": true\r\n}"
```