ba0f3 / telebot.nim

Async Telegram Bot API Client implement in @Nim-Lang
MIT License
165 stars 24 forks source link

InlineKeyboard not working #88

Closed ZerrosX closed 11 months ago

ZerrosX commented 1 year ago
import telebot, asyncdispatch, logging, options, strutils
const TOKEN_API = "" # secret key

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 = initInlineKeyboardButton("Google", url = "https://www.google.com/search?q=" & text)
      bing = initInlineKeyboardButton("Bing", url = "https://www.bing.com/search?q=" & text)
      ddg = initInlineKeyboardButton("DuckDuckGo", url = "https://duckduckgo.com/?q=" & text)
      searx = initInlineKeyboardButton("searx.me", url = "https://searx.me/?q=" & text)
    let replyMarkup = newInlineKeyboardMarkup(@[google, bing], @[ddg, searx])
    discard await b.sendMessage(response.chat.id, text, replyMarkup = replyMarkup)

when isMainModule:
  let bot = newTeleBot(TOKEN_API)

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

Good afternoon, can you please tell me what I am doing wrong? I run the script with nim r -d:ssl main.nim But still, when I write something to the bot, it sends me echo text , without creating inline buttons.

ba0f3 commented 11 months ago

this code works as expected image