Handle deeplinks and respond from database
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
5be6fb18ba
commit
5dc6903291
1 changed files with 17 additions and 2 deletions
|
@ -30,8 +30,23 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
|
||||||
let response = u.message.get
|
let response = u.message.get
|
||||||
if response.text.isSome:
|
if response.text.isSome:
|
||||||
let message = response.text.get
|
let message = response.text.get
|
||||||
if message.contains("/start"):
|
if message == "/start":
|
||||||
|
discard await b.sendMessage(response.chat.id, "Hey, To create a censored post, you can share any album, video, photo, gif, sticker, etc. The messages could then be forwarded to any chat for them to view")
|
||||||
|
elif message.contains("/start"):
|
||||||
let deeplink = message.split(" ")
|
let deeplink = message.split(" ")
|
||||||
|
var TempData = @[NewCensoredData()]
|
||||||
|
dbConn.select(TempData, "fhash = ?", deeplink[1])
|
||||||
|
for i in TempData:
|
||||||
|
if i.ftype == "photo":
|
||||||
|
discard await b.sendPhoto(response.chat.id, i.fileid, i.caption)
|
||||||
|
if i.ftype == "document":
|
||||||
|
discard await b.sendDocument(response.chat.id, i.fileid, i.caption)
|
||||||
|
if i.ftype == "video":
|
||||||
|
discard await b.sendVideo(response.chat.id, i.fileid, caption=i.caption)
|
||||||
|
if i.ftype == "videonote":
|
||||||
|
discard await b.sendVideoNote(response.chat.id, i.fileid)
|
||||||
|
if i.ftype == "animation":
|
||||||
|
discard await b.sendAnimation(response.chat.id, i.fileid, caption=i.caption)
|
||||||
else:
|
else:
|
||||||
var fileid = ""
|
var fileid = ""
|
||||||
var ftype = ""
|
var ftype = ""
|
||||||
|
@ -63,7 +78,7 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
|
||||||
with dbConn:
|
with dbConn:
|
||||||
insert CensoredRow
|
insert CensoredRow
|
||||||
|
|
||||||
discard b.sendMessage(response.chat.id, "Censored --> " & "tg://resolve?domain=botbotbotnotabot%26start=" & filehash)
|
discard await b.sendMessage(response.chat.id, "Censored --> " & "tg://resolve?domain=botbotbotnotabot&start=" & filehash)
|
||||||
|
|
||||||
let bot = newTeleBot(API_KEY)
|
let bot = newTeleBot(API_KEY)
|
||||||
bot.onUpdate(updateHandler)
|
bot.onUpdate(updateHandler)
|
||||||
|
|
Loading…
Reference in a new issue