Dolfik1/Funogram

Field "inline_keyboard" should be an Array of Arrays

worldbeater opened this issue · 2 comments

Trying to send message using inline keyboard markup but can not succeed. Using latest Funogram build version 1.1.3-alpha. In order to reproduce the bug this function can be used:

let createInlineLinkMarkup (url: string) (caption: string) =
  let redirectButton = 
    { Text = caption
      Url = Some url 
      CallbackData = None
      SwitchInlineQuery = None
      SwitchInlineQueryCurrentChat = None 
      CallbackGame = None }
  let buttons = ([ redirectButton ], [ redirectButton ])
  Markup.InlineKeyboardMarkup {
   InlineKeyboard = List.singleton buttons }

Fails with:

Bad Request: field "inline_keyboard" of the InlineKeyboardMarkup should be an Array of Arrays

POSSIBLE SOLUTION

InlineKeyboard type definition seems to be broken. Is:

type InlineKeyboardMarkup =
      { /// Array of button rows, each represented by an Array of InlineKeyboardButton objects
        InlineKeyboard: (InlineKeyboardButton list * InlineKeyboardButton list) list }

But should be array of arrays as stated in API docs.

UPDATE 1

Performed some tests, lists are not actually working (receiving error "Bad Request: field "inline_keyboard" should be an Object"), but with type seq everything works okay. So, here is a piece of code that should be better used in the library:

type InlineKeyboardMarkup =
      { /// Array of button rows, each represented by an Array of InlineKeyboardButton objects
        InlineKeyboard: (InlineKeyboardButton seq) seq }

For an ease of access I'll pull request with this fix.
Thanks for your awesome work, @Dolfik1!

Well, this issue is fixed in Funogram 1.2.1 update.

The issue returns in 1.2.2 update!
This PR fixes it: #13