Move the censoring logic to else clause

We dont ideally need this check when there is just plaintext

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-04-09 22:25:11 +05:30
parent 2f859b5735
commit 6c0db09773
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -32,33 +32,38 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
let message = response.text.get
if message.contains("/start"):
let deeplink = message.split(" ")
var fileid = ""
var ftype = ""
var fcaption = ""
if response.caption.isSome:
fcaption = response.caption.get
if response.document.isSome:
fileid = response.document.get.fileId
ftype = "document"
if response.video.isSome:
fileid = response.video.get.fileId
ftype = "video"
if response.videoNote.isSome:
fileid = response.videoNote.get.fileId
ftype = "videonote"
if response.animation.isSome:
fileid = response.animation.get.fileId
ftype = "animation"
if response.photo.isSome:
fileid = response.photo.get[0].fileId
ftype = "photo"
else:
var fileid = ""
var ftype = ""
var fcaption = ""
if response.caption.isSome:
fcaption = response.caption.get
if response.document.isSome:
fileid = response.document.get.fileId
ftype = "document"
if response.video.isSome:
fileid = response.video.get.fileId
ftype = "video"
if response.videoNote.isSome:
fileid = response.videoNote.get.fileId
ftype = "videonote"
if response.animation.isSome:
fileid = response.animation.get.fileId
ftype = "animation"
if response.photo.isSome:
fileid = response.photo.get[0].fileId
ftype = "photo"
if response.mediaGroupId.isSome:
fileid = response.mediaGroupId.get
let filehash = generate_hash()
let filehash = generate_hash()
var CensoredRow = NewCensoredData(ftype, filehash, fileid, fcaption)
var CensoredRow = NewCensoredData(ftype, filehash, fileid, fcaption)
with dbConn:
insert CensoredRow
with dbConn:
insert CensoredRow
discard b.sendMessage(response.chat.id, "Censored --> " & "tg://resolve?domain=botbotbotnotabot%26start=" & filehash)
let bot = newTeleBot(API_KEY)
bot.onUpdate(updateHandler)