Perform a nice cleanup of the mess
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
63e08ca1c6
commit
2f859b5735
2 changed files with 21 additions and 20 deletions
0
censorbot.db
Normal file
0
censorbot.db
Normal 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)
|
||||
|
|
Loading…
Reference in a new issue