Add a check for non-existent hash

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-04-09 23:18:48 +05:30
parent 9c41348338
commit ba91151766
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -46,28 +46,30 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
discard await b.sendMessage(response.chat.id, "Hey, To create a censored post, you can share any album, video, photo, gif, sticker, etc. The messages could then be forwarded to any chat for them to view")
elif message.contains("/ban"):
let user = message.split(" ")
echo "BANNING"
var BannedUser = NewBannedUsers(user[1])
with dbConn:
insert BannedUser
discard await b.sendMessage(response.chat.id, "Banned!")
elif message.contains("/start"):
let deeplink = message.split(" ")
var TempData = @[NewCensoredData()]
dbConn.select(TempData, "fhash = ?", deeplink[1])
for i in TempData:
if i.ftype == "photo":
discard await b.sendPhoto(response.chat.id, i.fileid, i.caption)
elif i.ftype == "document":
discard await b.sendDocument(response.chat.id, i.fileid, i.caption)
elif i.ftype == "video":
discard await b.sendVideo(response.chat.id, i.fileid, caption=i.caption)
elif i.ftype == "videonote":
discard await b.sendVideoNote(response.chat.id, i.fileid)
elif i.ftype == "animation":
discard await b.sendAnimation(response.chat.id, i.fileid, caption=i.caption)
elif i.ftype == "sticker":
discard await b.sendSticker(response.chat.id, i.fileid)
if not dbConn.exists(CensoredData, "fhash = ?", deeplink[1]):
discard await b.sendMessage(response.chat.id, "Media does not exist on database, ask the sender to censor this again!")
else:
var TempData = @[NewCensoredData()]
dbConn.select(TempData, "fhash = ?", deeplink[1])
for i in TempData:
if i.ftype == "photo":
discard await b.sendPhoto(response.chat.id, i.fileid, i.caption)
elif i.ftype == "document":
discard await b.sendDocument(response.chat.id, i.fileid, i.caption)
elif i.ftype == "video":
discard await b.sendVideo(response.chat.id, i.fileid, caption=i.caption)
elif i.ftype == "videonote":
discard await b.sendVideoNote(response.chat.id, i.fileid)
elif i.ftype == "animation":
discard await b.sendAnimation(response.chat.id, i.fileid, caption=i.caption)
elif i.ftype == "sticker":
discard await b.sendSticker(response.chat.id, i.fileid)
else:
var fileid = ""
var ftype = ""
@ -92,8 +94,6 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
elif response.sticker.isSome:
fileid = response.sticker.get.fileId
ftype = "sticker"
elif response.mediaGroupId.isSome:
fileid = response.mediaGroupId.get
let filehash = generate_hash()