Skip to content

Commit 3fd1fc4

Browse files
committed
Add example for ForceReply markup
1 parent a50f043 commit 3fd1fc4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/force_reply.nim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import telebot, asyncdispatch, logging, options
2+
from strutils import strip
3+
4+
var L = newConsoleLogger()
5+
addHandler(L)
6+
7+
const API_KEY = slurp("secret.key").strip()
8+
9+
proc updateHandler(b: Telebot, u: Update): Future[bool] {.gcsafe, async.} =
10+
var response = u.message.get
11+
if response.text.isSome:
12+
let
13+
text = response.text.get
14+
replyMarkup = newForceReply(true, "Input:")
15+
16+
discard await b.sendMessage(response.chat.id, text, replyMarkup = replyMarkup)
17+
18+
when isMainModule:
19+
let bot = newTeleBot(API_KEY)
20+
21+
bot.onUpdate(updateHandler)
22+
bot.poll(timeout=300)

0 commit comments

Comments
 (0)