Insert data flowing into the db
* File hash is still broken, we will do it now Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
b7b94085b3
commit
298431fe38
1 changed files with 21 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
import telebot, std/[asyncdispatch, logging, options, strutils, random], norm/[model, sqlite]
|
||||
import telebot, std/[asyncdispatch, logging, options, strutils, random, with], norm/[model, sqlite]
|
||||
|
||||
type
|
||||
CENSORED_DATA* = ref object of Model
|
||||
|
@ -26,16 +26,28 @@ proc generate_hash(): string=
|
|||
# remember to strip your secret key to avoid HTTP error
|
||||
const API_KEY = ""
|
||||
|
||||
proc updateHandler(b: Telebot, u: Update): Future[bool] {.async.} =
|
||||
proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
|
||||
var response = u.message.get
|
||||
#if response.document.isSome:
|
||||
|
||||
#if response.video.isSome:
|
||||
#if response.videoNote.isSome:
|
||||
#if response.animation.isSome:
|
||||
if response.document.isSome:
|
||||
var censordoc = newCENSORED_DATA("document", response.photo.get[0].fileId, "")
|
||||
with dbConn:
|
||||
insert censordoc
|
||||
if response.video.isSome:
|
||||
var censorvid = newCENSORED_DATA("video", response.photo.get[0].fileId, "")
|
||||
with dbConn:
|
||||
insert censorvid
|
||||
if response.videoNote.isSome:
|
||||
var censorvidnote = newCENSORED_DATA("videonote", response.photo.get[0].fileId, "")
|
||||
with dbConn:
|
||||
insert censorvidnote
|
||||
if response.animation.isSome:
|
||||
var censoranimation = newCENSORED_DATA("animation", response.photo.get[0].fileId, "")
|
||||
with dbConn:
|
||||
insert censoranimation
|
||||
if response.photo.isSome:
|
||||
discard await b.sendPhoto(response.chat.id, response.photo.get[0].fileId)
|
||||
echo "Found file"
|
||||
var censorphoto = newCENSORED_DATA("photo", response.photo.get[0].fileId, "")
|
||||
with dbConn:
|
||||
insert censorphoto
|
||||
|
||||
let bot = newTeleBot(API_KEY)
|
||||
bot.onUpdate(updateHandler)
|
||||
|
|
Loading…
Reference in a new issue