Add db stuff
Just a basic ORM structure with norm Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
00af7346c1
commit
b7b94085b3
2 changed files with 17 additions and 3 deletions
|
@ -11,4 +11,5 @@ bin = @["nim_censor_bot"]
|
|||
# Dependencies
|
||||
|
||||
requires "nim >= 1.6.0"
|
||||
requires "telebot"
|
||||
requires "telebot"
|
||||
requires "norm"
|
|
@ -1,4 +1,18 @@
|
|||
import telebot, std/[asyncdispatch, logging, options, strutils, random]
|
||||
import telebot, std/[asyncdispatch, logging, options, strutils, random], norm/[model, sqlite]
|
||||
|
||||
type
|
||||
CENSORED_DATA* = ref object of Model
|
||||
ftype*: string
|
||||
fileid*: string
|
||||
caption*: string
|
||||
|
||||
func newCENSORED_DATA*(ftype = ""; fileid = ""; caption = ""):
|
||||
CENSORED_DATA = CENSORED_DATA(ftype: ftype, fileid: fileid, caption: caption)
|
||||
|
||||
let dbConn* = sqlite.open("censordata.db", "", "", "")
|
||||
|
||||
dbConn.createTables(newCENSORED_DATA())
|
||||
|
||||
var L = newConsoleLogger(fmtStr="$levelname, [$time] ")
|
||||
addHandler(L)
|
||||
|
||||
|
@ -20,7 +34,6 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async.} =
|
|||
#if response.videoNote.isSome:
|
||||
#if response.animation.isSome:
|
||||
if response.photo.isSome:
|
||||
echo generate_hash()
|
||||
discard await b.sendPhoto(response.chat.id, response.photo.get[0].fileId)
|
||||
echo "Found file"
|
||||
|
||||
|
|
Loading…
Reference in a new issue