2024-06-05 10:19:46 +00:00
|
|
|
---
|
|
|
|
sidebar_position: 12
|
|
|
|
---
|
|
|
|
|
|
|
|
# Generate keyboard from array of buttons
|
|
|
|
Generates a simple JSON keyboard from an array of buttons for a message or bottom panel
|
|
|
|
|
|
|
|
|
2024-07-10 11:59:55 +03:00
|
|
|
|
2024-07-10 13:58:29 +03:00
|
|
|
`Function FormKeyboardFromButtonArray(Val ButtonArray, Val UnderMessage = False, Val OneByOne = True) Export`
|
2024-06-05 10:19:46 +00:00
|
|
|
|
2024-08-13 15:52:26 +03:00
|
|
|
| Parameter | CLI option | Type | 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-06-05 10:19:46 +00:00
|
|
|
|
2024-08-13 15:52:26 +03:00
|
|
|
|
|
|
|
Returns: String - Keyboard JSON
|
2024-06-05 10:19:46 +00:00
|
|
|
|
2024-07-10 14:05:58 +03:00
|
|
|
<br/>
|
2024-07-10 11:59:55 +03:00
|
|
|
|
2024-10-11 09:59:59 +03:00
|
|
|
:::tip
|
|
|
|
About keyboards in the API documentation: [InlineKeyboardMarkup](https://core.telegram.org/bots/api#inlinekeyboardmarkup)
|
|
|
|
:::
|
|
|
|
<br/>
|
2024-07-10 13:58:29 +03:00
|
|
|
|
|
|
|
|
2024-06-05 10:19:46 +00:00
|
|
|
```bsl title="Code example"
|
2024-10-03 20:35:39 +03:00
|
|
|
ButtonArray = New Array;
|
|
|
|
ButtonArray.Add("Button1");
|
|
|
|
ButtonArray.Add("Button2");
|
|
|
|
ButtonArray.Add("Button3");
|
|
|
|
|
|
|
|
Result = OPI_Telegram.FormKeyboardFromButtonArray(ButtonArray);
|
2024-06-05 10:19:46 +00:00
|
|
|
```
|
2024-10-15 09:53:37 +03:00
|
|
|
|
2024-08-13 15:52:26 +03:00
|
|
|
|
2024-07-10 11:59:55 +03:00
|
|
|
|
2024-06-05 10:19:46 +00:00
|
|
|
|
|
|
|
```json title="Result"
|
2024-10-06 16:55:08 +03:00
|
|
|
"{\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}"
|
2024-06-05 10:19:46 +00:00
|
|
|
```
|