Skip to content

Commit ab4fb86

Browse files
committed
add url w/ parameters handling
1 parent 7a63e9b commit ab4fb86

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

telebot.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import json
44
import strutils
55
import tempfile
66
import os
7+
import uri
78

89
const
910
API_URL = "https://api.telegram.org/bot$#/$#"
@@ -438,7 +439,8 @@ proc sendPhoto*(b: TeleBot, chatId: int, photo: string, resend = false,cap = "",
438439
data["photo"] = photo
439440
else:
440441
if photo.startsWith("http"):
441-
var (_, _, ext) = photo.splitFile()
442+
let u = parseUri(photo)
443+
var (_, _, ext) = u.path.splitFile()
442444
let tmp = mktemp(suffix=ext)
443445
downloadFile(photo, tmp)
444446
data.addFiles({"photo": tmp})

0 commit comments

Comments
 (0)