ba0f3 / telebot.nim

Async Telegram Bot API Client implement in @Nim-Lang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`umarshal` function tries to extract `type` field for `InlineKeyboardMarkup` from corresponding JSON, which is not available

hamidb80 opened this issue · comments

Hey,
I just found out that example/inline_query_with_input_message_content.nim does not work.

I followed the stack trace which was:

>>>  key not found: type
Async traceback:
  \azmmonak\bot\src\main.nim(417)             main
  \telebot\src\telebot\private\api.nim(1185)  poll
  \toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(1961)     waitFor
  \toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(1653)     poll
  \toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(419)      runOnce
  \toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(234)      processPendingCallbacks
  \toolchains\nim-1.6.2\lib\pure\asyncmacro.nim(28)          loopNimAsyncContinue
  \telebot\src\telebot\private\api.nim(1179)  loopIter
  \telebot\src\telebot\private\utils.nim(100) unmarshal
  \telebot\src\telebot\private\utils.nim(213) toOption
  \telebot\src\telebot\private\utils.nim(184) unref
  \telebot\src\telebot\private\utils.nim(100) unmarshal
  \telebot\src\telebot\private\utils.nim(199) toOption
  \telebot\src\telebot\private\utils.nim(100) unmarshal
  \telebot\src\telebot\private\utils.nim(213) toOption
  \telebot\src\telebot\private\utils.nim(184) unref
  \telebot\src\telebot\private\utils.nim(110) unmarshal
  \toolchains\nim-1.6.2\lib\pure\json.nim(517)               []
  \toolchains\nim-1.6.2\lib\pure\collections\tables.nim(246) []
  \toolchains\nim-1.6.2\lib\pure\collections\tables.nim(234) raiseKeyError
Exception message: key not found: type

and I put some lines for logging after this line

debugEcho name," >> ", value.type, " :: ", jsonKey, " == ", typeof result
debugecho "JSON||", n

as I try to click on the inline button, the last thing that is logged is:

type >> KeyboardKind :: type == InlineKeyboardMarkup:ObjectType
JSON||{"inline_keyboard":[[{"text":"xxx","callback_data":"/t6"}]]}

it looks like the unmarshal function tries to get type field from that JSON

ah I get it, I will fix it soon

I think the type field is mostly used for object variants, for OOP style we can use of operator to check inheritance.

I guees you should bump the version, because nimble still downloads the old one

I think the type field is mostly used for object variants, for OOP style we can use of operator to check inheritance.

it was a dirty hack, cuz any Telegram objecttype field will be transform to kind when marshalling, so type field will never exists in any Telegram object