Split strings for readability
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
31ae8e1c1f
commit
82083fedf7
1 changed files with 41 additions and 7 deletions
|
@ -108,10 +108,13 @@ proc startHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} =
|
|||
else:
|
||||
RateLimiter[c.message.chat.id] = @[epochTime()]
|
||||
if param == "":
|
||||
discard await b.sendMessage(c.message.chat.id, "Hey, To create a censored post, you can share any album, video, photo, gif, sticker, etc. The response of the bot can be used to share the media with other chats.")
|
||||
discard await b.sendMessage(c.message.chat.id,
|
||||
"Hey, To create a censored post, you can share any album, video, photo, gif, sticker, etc." &
|
||||
"The response of the bot can be used to share the media with other chats.")
|
||||
else:
|
||||
if not dbConn.exists(CensoredData, "fhash = ?", param):
|
||||
discard await b.sendMessage(c.message.chat.id, "Media does not exist on database, ask the sender to censor this again!")
|
||||
discard await b.sendMessage(c.message.chat.id,
|
||||
"Media does not exist on database, ask the sender to censor this again!")
|
||||
else:
|
||||
var TempData = @[NewCensoredData()]
|
||||
dbConn.select(TempData, "fhash = ?", param)
|
||||
|
@ -146,7 +149,12 @@ proc sourceHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} =
|
|||
RateLimiter[c.message.chat.id].insert(epochTime())
|
||||
else:
|
||||
RateLimiter[c.message.chat.id] = @[epochTime()]
|
||||
discard await b.sendMessage(c.message.chat.id, "Hey, this bot is open-source and licensed under AGPL-v3! \n\nYou are welcome to selfhost your own instance of this bot\n\nThe source code is [here](https://git.baalajimaestro.me/baalajimaestro/nim-censor-bot)", parseMode="Markdown", disableWebPagePreview = true)
|
||||
discard await b.sendMessage(c.message.chat.id,
|
||||
"Hey, this bot is open-source and licensed under AGPL-v3! " &
|
||||
"\n\nYou are welcome to selfhost your own instance of this bot" &
|
||||
"\n\nThe source code is [here](https://git.baalajimaestro.me/baalajimaestro/nim-censor-bot)",
|
||||
parseMode="Markdown",
|
||||
disableWebPagePreview = true)
|
||||
|
||||
# UnBan Handler
|
||||
proc unbanHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} =
|
||||
|
@ -179,7 +187,8 @@ proc inlineHandler(b: Telebot, u: InlineQuery): Future[bool]{.async.} =
|
|||
res.id = "1"
|
||||
if not dbConn.exists(CensoredData, "fhash = ?",u.query):
|
||||
res.title = "Media Not Found"
|
||||
res.inputMessageContent = InputTextMessageContent("Media Not Found").some
|
||||
res.inputMessageContent = InputTextMessageContent(
|
||||
"Media does not exist on database, ask the sender to censor this again!").some
|
||||
else:
|
||||
dbConn.select(TempData, "fhash = ?", u.query)
|
||||
if len(TempData) > 1:
|
||||
|
@ -187,7 +196,14 @@ proc inlineHandler(b: Telebot, u: InlineQuery): Future[bool]{.async.} =
|
|||
elif len(TempData) == 1:
|
||||
ftype = TempData[0].ftype
|
||||
res.title = "Censored " & capitalizeAscii(ftype)
|
||||
res.inputMessageContent = InputMessageContent(kind: TextMessage, messageText:"*Censored " & capitalizeAscii(ftype) & "*\n\n[Tap to View](tg://resolve?domain=" & b.username & "&start=" & u.query & ")", parseMode: some("Markdown")).some
|
||||
res.inputMessageContent = InputMessageContent(kind: TextMessage,
|
||||
messageText:"*Censored " &
|
||||
capitalizeAscii(ftype) &
|
||||
"*\n\n[Tap to View](tg://resolve?domain=" &
|
||||
b.username & "&start=" &
|
||||
u.query &
|
||||
")",
|
||||
parseMode: some("Markdown")).some
|
||||
results.add(res)
|
||||
discard await b.answerInlineQuery(u.id, results)
|
||||
|
||||
|
@ -239,7 +255,16 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
|
|||
insert CensoredRow
|
||||
var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash))
|
||||
let replymark = newInlineKeyboardMarkup(@[replybutton])
|
||||
discard await b.sendMessage(response.chat.id, "*Censored " & capitalizeAscii(ftype) & "*\n\n[Tap to View](tg://resolve?domain=" & b.username & "&start=" & filehash & ")", replyMarkup = replymark, parseMode="Markdown")
|
||||
discard await b.sendMessage(response.chat.id,
|
||||
"*Censored " &
|
||||
capitalizeAscii(ftype) &
|
||||
"*\n\n[Tap to View](tg://resolve?domain=" &
|
||||
b.username &
|
||||
"&start=" &
|
||||
filehash &
|
||||
")",
|
||||
replyMarkup = replymark,
|
||||
parseMode="Markdown")
|
||||
else:
|
||||
let filehash = GroupMedia[parseInt(response.mediaGroupId.get)]
|
||||
var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption)
|
||||
|
@ -253,7 +278,16 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
|
|||
insert CensoredRow
|
||||
var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash))
|
||||
let replymark = newInlineKeyboardMarkup(@[replybutton])
|
||||
discard await b.sendMessage(response.chat.id, "*Censored " & capitalizeAscii(ftype) & "*\n\n[Tap to View](tg://resolve?domain=" & b.username & "&start=" & filehash & ")", replyMarkup = replymark, parseMode="Markdown")
|
||||
discard await b.sendMessage(response.chat.id,
|
||||
"*Censored " &
|
||||
capitalizeAscii(ftype) &
|
||||
"*\n\n[Tap to View](tg://resolve?domain=" &
|
||||
b.username &
|
||||
"&start=" &
|
||||
filehash &
|
||||
")",
|
||||
replyMarkup = replymark,
|
||||
parseMode="Markdown")
|
||||
OldDataCleanup()
|
||||
|
||||
when isMainModule:
|
||||
|
|
Loading…
Reference in a new issue