Modify the functions to reflect the change in schema

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-04-11 09:50:07 +05:30
parent 2dea576b58
commit e8efd87f71
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -27,8 +27,8 @@ let AdminID = getEnv("ADMIN_ID").split(",")
let dbConn* = getDb()
func NewCensoredData*(ftype = ""; fhash = ""; fileid = ""; caption = ""):
CensoredData = CensoredData(ftype: ftype, fhash: fhash, fileid: fileid, caption: caption)
func NewCensoredData*(ftype = ""; fhash = ""; fileid = ""; time = 0.0; caption = ""):
CensoredData = CensoredData(ftype: ftype, fhash: fhash, fileid: fileid, time: time, caption: caption)
func NewBannedUsers*(userid = int64(0), bantime = 0.0, bantype = ""):
BannedUsers = BannedUsers(userid: userid, bantime: bantime, bantype: bantype)
@ -143,19 +143,19 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
if parseInt(response.mediaGroupId.get) notin GroupMedia.keys().toSeq():
let filehash = generate_hash()
GroupMedia[parseInt(response.mediaGroupId.get)] = filehash
var CensoredRow = NewCensoredData(ftype, filehash, fileid, fcaption)
var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption)
with dbConn:
insert CensoredRow
discard await b.sendMessage(response.chat.id, "Censored --> " & "tg://resolve?domain=botbotbotnotabot&start=" & filehash)
else:
let filehash = GroupMedia[parseInt(response.mediaGroupId.get)]
var CensoredRow = NewCensoredData(ftype, filehash, fileid, fcaption)
var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption)
with dbConn:
insert CensoredRow
else:
let filehash = generate_hash()
var CensoredRow = NewCensoredData(ftype, filehash, fileid, fcaption)
var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption)
with dbConn:
insert CensoredRow
discard await b.sendMessage(response.chat.id, "Censored --> " & "tg://resolve?domain=botbotbotnotabot&start=" & filehash)