newForceReply not prompting reply interface and a possible solution
samsamros opened this issue · comments
Samuel commented
Hello again...
I've been trying to implement the force reply option as stated in the telegram docs: https://core.telegram.org/bots/api#sendmessage and https://core.telegram.org/bots/api#forcereply
The following example was not working:
proc askme(b: Telebot, c:Command): Future[bool] {.async.} =
var
username = $c.message.fromUser.get().username.get()
let replyMarkup = newForceReply(selective = true)
discard await b.sendMessage(parseInt(chat), "u drunk @$1?" % username, replyMarkup = replyMarkup)
After analyzing the code I was able to make this work by editing the following code:
In Types.nim:
ForceReply* = ref object of KeyboardMarkup
forceReply*: Option[bool] ## added this
inputFieldPlaceholder*: Option[string]
In keyboard.nim
proc newForceReply*(selective: bool, inputFieldPlaceholder = ""): ForceReply =
new(result)
result.kind = kForceReply
result.forceReply = some(true) ## added this
result.selective = some(selective)
if inputFieldPlaceholder.len != 0:
result.inputFieldPlaceholder = some(inputFieldPlaceholder)
the code now works for me and prompts the reply after issuing the command. I don't know if this has been an issue before, but I hope it helps :)
Huy Doan commented
I will check it soon
Huy Doan commented
oh yes, force_reply
was missing in ForceReply
keyboard type, thank you