Add a check for non-existent hash
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
9c41348338
commit
ba91151766
1 changed files with 18 additions and 18 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue