Created
December 30, 2021 21:17
-
-
Save hamidb80/1e37a2780e2ff18bf906fc19cf2e24d3 to your computer and use it in GitHub Desktop.
telebot send contact info reply to message causes error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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