0
votes

I try to send messages in telegram with adding strings in inline keyboard table for telegram sends a message I make the text for keyboard format with, for loop like this

 for k,v in pairs(list) do 
text = text.."{{".."text="..v.."}},"
end
 local keyboard = {}
      keyboard.inline_keyboard = {
           text 
       }

`

How I can convert to text string to keyboard table? I use this code but doesn't work because that is a string in table!

1

1 Answers

0
votes

As I understand

inline_keyboard - Array of Array of InlineKeyboardButton

and so example of code:

local list = {"TextButton1","TextButton2","TextButton3"}
local buttons = {}

 for k,v in pairs(list) do 
    buttons[#buttons+1] = { text=v }
end

 local keyboard = {}
keyboard.inline_keyboard = {  buttons  }

print( keyboard.inline_keyboard[1][1].text)

maybe you need correct the code.