Dont make db calls if the inline query is null
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
4b0974bfa1
commit
33894b0501
1 changed files with 23 additions and 18 deletions
|
@ -187,25 +187,30 @@ proc inlineHandler(b: Telebot, u: InlineQuery): Future[bool]{.async.} =
|
||||||
var results: seq[InlineQueryResultArticle]
|
var results: seq[InlineQueryResultArticle]
|
||||||
res.kind = "article"
|
res.kind = "article"
|
||||||
res.id = "1"
|
res.id = "1"
|
||||||
if not dbConn.exists(CensoredData, "fhash = ?",u.query):
|
if u.query != "":
|
||||||
res.title = "Media Not Found"
|
if not dbConn.exists(CensoredData, "fhash = ?",u.query):
|
||||||
res.inputMessageContent = InputTextMessageContent(
|
res.title = "Media Not Found"
|
||||||
"Media does not exist on database, ask the sender to censor this again!").some
|
res.inputMessageContent = InputTextMessageContent(
|
||||||
|
"Media does not exist on database, ask the sender to censor this again!").some
|
||||||
|
else:
|
||||||
|
dbConn.select(TempData, "fhash = ?", u.query)
|
||||||
|
if len(TempData) > 1:
|
||||||
|
ftype = "Album"
|
||||||
|
elif len(TempData) == 1:
|
||||||
|
ftype = TempData[0].ftype
|
||||||
|
res.title = "NSFW " & capitalizeAscii(ftype)
|
||||||
|
res.inputMessageContent = InputMessageContent(kind: TextMessage,
|
||||||
|
messageText:"*NSFW " &
|
||||||
|
capitalizeAscii(ftype) &
|
||||||
|
"*\n\n[Tap to View](tg://resolve?domain=" &
|
||||||
|
b.username & "&start=" &
|
||||||
|
u.query &
|
||||||
|
")",
|
||||||
|
parseMode: some("Markdown")).some
|
||||||
else:
|
else:
|
||||||
dbConn.select(TempData, "fhash = ?", u.query)
|
res.title = "Waiting for File Hash"
|
||||||
if len(TempData) > 1:
|
res.inputMessageContent = InputTextMessageContent(
|
||||||
ftype = "Album"
|
"Provide the filehash on inline query").some
|
||||||
elif len(TempData) == 1:
|
|
||||||
ftype = TempData[0].ftype
|
|
||||||
res.title = "NSFW " & capitalizeAscii(ftype)
|
|
||||||
res.inputMessageContent = InputMessageContent(kind: TextMessage,
|
|
||||||
messageText:"*NSFW " &
|
|
||||||
capitalizeAscii(ftype) &
|
|
||||||
"*\n\n[Tap to View](tg://resolve?domain=" &
|
|
||||||
b.username & "&start=" &
|
|
||||||
u.query &
|
|
||||||
")",
|
|
||||||
parseMode: some("Markdown")).some
|
|
||||||
results.add(res)
|
results.add(res)
|
||||||
discard await b.answerInlineQuery(u.id, results)
|
discard await b.answerInlineQuery(u.id, results)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue