Skip to content

Instantly share code, notes, and snippets.

@hamidb80
Created December 30, 2021 21:17
Show Gist options
  • Save hamidb80/1e37a2780e2ff18bf906fc19cf2e24d3 to your computer and use it in GitHub Desktop.
Save hamidb80/1e37a2780e2ff18bf906fc19cf2e24d3 to your computer and use it in GitHub Desktop.
telebot send contact info reply to message causes error
import telebot, asyncdispatch, logging, options
var L = newConsoleLogger(fmtStr = "$levelname, [$time] ")
addHandler(L)
func singleReply*(btn: KeyboardButton): ReplyKeyboardMarkup =
ReplyKeyboardMarkup(`type`: kReplyKeyboardMarkup, keyboard: @[@[btn]])
const API_KEY = "..."
proc updateHandler(b: Telebot, u: Update): Future[bool] {.gcsafe, async.} =
if u.message.isSome:
var response = u.message.get
discard await b.sendMessage(
response.chat.id,
"check the virtual keyboard",
replyMarkup = singleReply(
KeyboardButton(text: "send your contact", requestContact: some true)
)
)
return true
let bot = newTeleBot(API_KEY)
while true:
try:
bot.onUpdate(updateHandler)
bot.poll(timeout=300)
except:
echo getCurrentExceptionMsg()
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment