Skip to content

Commit 9333f69

Browse files
committed
fix file_receive_bot example
1 parent 046c01d commit 9333f69

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/file_receive_bot/file_receive_bot.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# This Bot receives any Document file, responds on chat with file metadata and file contents.
22
import telebot, asyncdispatch, options, strformat, httpclient, json
3+
from strutils import strip
34

4-
const API_KEY = slurp("secret.key")
55

6+
const API_KEY = slurp("../secret.key").strip()
67

7-
proc updateHandler(bot: TeleBot, e: Update) {.async.} =
8+
9+
proc updateHandler(bot: TeleBot, e: Update): Future[bool] {.async.} =
810
let
911
url_getfile = fmt"https://api.telegram.org/bot{API_KEY}/getFile?file_id="
1012
api_file = fmt"https://api.telegram.org/file/bot{API_KEY}/"
1113

14+
if not e.message:
15+
return true
1216
var response = e.message.get
1317
if response.document.isSome:
1418
let

0 commit comments

Comments
 (0)