Perform a nice cleanup of the mess

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-04-09 22:10:27 +05:30
parent 63e08ca1c6
commit 2f859b5735
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5
2 changed files with 21 additions and 20 deletions

0
censorbot.db Normal file
View file

View file

@ -33,31 +33,32 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
if message.contains("/start"):
let deeplink = message.split(" ")
var fileid = ""
let filehash = generate_hash()
var ftype = ""
var fcaption = ""
if response.caption.isSome:
fcaption = response.caption.get
if response.document.isSome:
var censordoc = NewCensoredData("document", filehash, response.document.get.fileId, "")
with dbConn:
insert censordoc
fileid = response.document.get.fileId
ftype = "document"
if response.video.isSome:
let filehash = generate_hash()
var censorvid = NewCensoredData("video", filehash, response.video.get.fileId, "")
with dbConn:
insert censorvid
fileid = response.video.get.fileId
ftype = "video"
if response.videoNote.isSome:
let filehash = generate_hash()
var censorvidnote = NewCensoredData("videonote", filehash, response.videoNote.get.fileId, "")
with dbConn:
insert censorvidnote
fileid = response.videoNote.get.fileId
ftype = "videonote"
if response.animation.isSome:
let filehash = generate_hash()
var censoranimation = NewCensoredData("animation", filehash, response.animation.get.fileId, "")
with dbConn:
insert censoranimation
fileid = response.animation.get.fileId
ftype = "animation"
if response.photo.isSome:
let filehash = generate_hash()
var censorphoto = NewCensoredData("photo", filehash, response.photo.get[0].fileId, "")
with dbConn:
insert censorphoto
fileid = response.photo.get[0].fileId
ftype = "photo"
let filehash = generate_hash()
var CensoredRow = NewCensoredData(ftype, filehash, fileid, fcaption)
with dbConn:
insert CensoredRow
let bot = newTeleBot(API_KEY)
bot.onUpdate(updateHandler)