1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2024-12-23 02:06:12 +02:00
OpenIntegrations/docs/en/md/Telegram/Data-sending/Form-keyboard-from-button-array.md

69 lines
1.5 KiB
Markdown
Raw Normal View History

---
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 12:58:29 +02:00
`Function FormKeyboardFromButtonArray(Val ButtonArray, Val UnderMessage = False, Val OneByOne = True) Export`
| Parameter | CLI option | Type | Destination |
|-|-|-|-|
| 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
2024-07-10 13:05:58 +02:00
<br/>
2024-07-10 12:58:29 +02:00
```bsl title="Code example"
2024-07-10 13:24:11 +02:00
ButtonArray = New Array;
ButtonArray.Add("Great");
ButtonArray.Add("Ok");
ButtonArray.Add("Bad");
Keyboard = OPI_Telegram.FormKeyboardFromButtonArray(ButtonArray, True, True);
```
```sh title="CLI command example"
oint telegram FormKeyboardFromButtonArray --buttons %buttons% --under %under% --column %column%
```
```json title="Result"
2024-07-10 13:11:17 +02:00
{
"inline_keyboard":[
[
{
"text":"\u041E\u0442\u043B\u0438\u0447\u043D\u043E",
"callback_data":"\u041E\u0442\u043B\u0438\u0447\u043D\u043E"
}
],
[
{
"text":"\u041D\u043E\u0440\u043C\u0430\u043B\u044C\u043D\u043E",
"callback_data":"\u041D\u043E\u0440\u043C\u0430\u043B\u044C\u043D\u043E"
}
],
[
{
"text":"\u041F\u043B\u043E\u0445\u043E",
"callback_data":"\u041F\u043B\u043E\u0445\u043E"
}
]
],
"rows":1
}
```