ba0f3 / telebot.nim

Async Telegram Bot API Client implement in @Nim-Lang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with oneTimeKeyboard in ReplyKeyboardMarkup. Keyboard not hiding after clicking on the button.

samsamros opened this issue · comments

I used the webapp example currently available in the examples but added the oneTimeKeyboard option to the ReplyKeyboardMarkup. However, after trying different approaches, my attempts have been unsuccessful.

import telebot, asyncdispatch, logging, options
from strutils import strip

var L = newConsoleLogger()
addHandler(L)

const API_KEY = slurp("secret.key").strip()

proc updateHandler(b: Telebot, u: Update): Future[bool] {.gcsafe, async.} =
  var response = u.message.get
  if response.text.isSome:
    let text = response.text.get
    var google = KeyboardButton(text: "Search the web", webApp: some WebAppInfo(url: "https://google.com"))

    let replyMarkup = ReplyKeyboardMarkup(kind: kReplyKeyboardMarkup, *oneTimeKeyboard: some(true)*, keyboard: @[@[google]])
# I also tried adding the bool statement as replyMarkup.oneTimeKeyboard = some(true)
    discard await b.sendMessage(response.chat.id, text, replyMarkup = replyMarkup)

when isMainModule:
  let bot = newTeleBot(API_KEY)

  bot.onUpdate(updateHandler)
  bot.poll(timeout=300)

According to the telgram bot documentation (https://core.telegram.org/bots/api/#replykeyboardmarkup), this option should hide the button as soon as it is clicked. However it is not working.
The Type ReplyKeyboardMarkup includes this option... I'm not sure if I'm making a mistake or did something wrong. I've also tried with every available option in the KeyboardButton, including location and contacts (var google = KeyboardButton(text: "Search the web", requestLocation:some(true)) instead of the code above in the same line.). The code otherwise works flawlessly and prompts a google site or requests a contact or my location; however, upon closing the app, the keyboard button still remains visible and does not hide.

I'm using telebot's latest code and nim 1.7.1
Thank you for your awesome work with this!

one_time_keyboard has been send to server, but I think it is a client's problem, not relate to the bot api

I think you're right @ba0f3 , after trying it with both desktop and mobile. It does hide in desktop but not in ios mobile. I will continue testing. Thank you for your response!