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,13 +46,15 @@ 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") 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"): elif message.contains("/ban"):
let user = message.split(" ") let user = message.split(" ")
echo "BANNING"
var BannedUser = NewBannedUsers(user[1]) var BannedUser = NewBannedUsers(user[1])
with dbConn: with dbConn:
insert BannedUser insert BannedUser
discard await b.sendMessage(response.chat.id, "Banned!") discard await b.sendMessage(response.chat.id, "Banned!")
elif message.contains("/start"): elif message.contains("/start"):
let deeplink = message.split(" ") let deeplink = message.split(" ")
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()] var TempData = @[NewCensoredData()]
dbConn.select(TempData, "fhash = ?", deeplink[1]) dbConn.select(TempData, "fhash = ?", deeplink[1])
for i in TempData: for i in TempData:
@ -92,8 +94,6 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
elif response.sticker.isSome: elif response.sticker.isSome:
fileid = response.sticker.get.fileId fileid = response.sticker.get.fileId
ftype = "sticker" ftype = "sticker"
elif response.mediaGroupId.isSome:
fileid = response.mediaGroupId.get
let filehash = generate_hash() let filehash = generate_hash()