Closed Alexsilvacodes closed 4 years ago
Hey, what method are you using? Could you send me a sample code?
Sure:
var buttons: [InlineKeyboardButton] = []
items.forEach { item in
let buttonDict = ["text": item.name, "callback_data": "item/\(item.id)"]
let button = InlineKeyboardButton(json: buttonDict)
buttons.append(button)
}
var matrix: [[InlineKeyboardButton]] = [[]]
while buttons.count > 1 {
matrix.append([buttons.removeFirst(), buttons.removeFirst()])
}
if buttons.count > 0 {
matrix.append([buttons.removeFirst()])
}
let buttonKeyboard = ["keyboard": matrix]
let keyboard = InlineKeyboardMarkup(json: buttonKeyboard)
context.respondAsync("Something",
reply_to_message_id: context.message?.messageId,
reply_markup: keyboard)
I've tried to use InlineKeyboardButton(json: "")
and InlineKeyboardMarkup(json: "")
, and after that, to set each property like this:
let button = InlineKeyboardButton(json: "")
button.text = "title"
I've tried too, to use bot.sendMessage
, in exchange for respondAsync
. Nothing works
Thank you, could you try using https://github.com/cipi1965/telegram-bot-swift.git rapier branch? I added an empty initializer to types, you should try setting properties of types
I wrote a sample project using the Inline Keyboard, would @cipi1965 like to put it in Examples? You can see it here.
https://github.com/HDCodePractice/CityHelper/tree/master/simple-keyboard
It also really took me a bit of time, and I'm sure I would have written the code out a bit faster if there had been relevant examples or documentation in the project.
Check @hdcola example, feel free to reopen this issue if you have problems
Hi! I'm trying to use reply markups with InlineKeyboardMarkup and ReplyKeyboardMarkup, but is not working for both types.
In the first place it doesn't allow me to reach
empty init
, but still if I try to create buttons and markups with the initializers present (json and data), I can see thatrawDictionary
contains the values that I'm using, but the parameterreply_markup
in the URL is sent empty and of course the buttons will not appear in the chat.Thank you