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"):
|
if message.contains("/start"):
|
||||||
let deeplink = message.split(" ")
|
let deeplink = message.split(" ")
|
||||||
var fileid = ""
|
var fileid = ""
|
||||||
let filehash = generate_hash()
|
var ftype = ""
|
||||||
|
var fcaption = ""
|
||||||
|
if response.caption.isSome:
|
||||||
|
fcaption = response.caption.get
|
||||||
if response.document.isSome:
|
if response.document.isSome:
|
||||||
var censordoc = NewCensoredData("document", filehash, response.document.get.fileId, "")
|
fileid = response.document.get.fileId
|
||||||
with dbConn:
|
ftype = "document"
|
||||||
insert censordoc
|
|
||||||
if response.video.isSome:
|
if response.video.isSome:
|
||||||
let filehash = generate_hash()
|
fileid = response.video.get.fileId
|
||||||
var censorvid = NewCensoredData("video", filehash, response.video.get.fileId, "")
|
ftype = "video"
|
||||||
with dbConn:
|
|
||||||
insert censorvid
|
|
||||||
if response.videoNote.isSome:
|
if response.videoNote.isSome:
|
||||||
let filehash = generate_hash()
|
fileid = response.videoNote.get.fileId
|
||||||
var censorvidnote = NewCensoredData("videonote", filehash, response.videoNote.get.fileId, "")
|
ftype = "videonote"
|
||||||
with dbConn:
|
|
||||||
insert censorvidnote
|
|
||||||
if response.animation.isSome:
|
if response.animation.isSome:
|
||||||
let filehash = generate_hash()
|
fileid = response.animation.get.fileId
|
||||||
var censoranimation = NewCensoredData("animation", filehash, response.animation.get.fileId, "")
|
ftype = "animation"
|
||||||
with dbConn:
|
|
||||||
insert censoranimation
|
|
||||||
if response.photo.isSome:
|
if response.photo.isSome:
|
||||||
let filehash = generate_hash()
|
fileid = response.photo.get[0].fileId
|
||||||
var censorphoto = NewCensoredData("photo", filehash, response.photo.get[0].fileId, "")
|
ftype = "photo"
|
||||||
with dbConn:
|
|
||||||
insert censorphoto
|
let filehash = generate_hash()
|
||||||
|
|
||||||
|
var CensoredRow = NewCensoredData(ftype, filehash, fileid, fcaption)
|
||||||
|
|
||||||
|
with dbConn:
|
||||||
|
insert CensoredRow
|
||||||
|
|
||||||
let bot = newTeleBot(API_KEY)
|
let bot = newTeleBot(API_KEY)
|
||||||
bot.onUpdate(updateHandler)
|
bot.onUpdate(updateHandler)
|
||||||
|
|
Loading…
Reference in a new issue