Split strings for readability

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-04-17 20:17:40 +05:30
parent 31ae8e1c1f
commit 82083fedf7
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -108,10 +108,13 @@ proc startHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} =
else: else:
RateLimiter[c.message.chat.id] = @[epochTime()] RateLimiter[c.message.chat.id] = @[epochTime()]
if param == "": 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: else:
if not dbConn.exists(CensoredData, "fhash = ?", param): 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: else:
var TempData = @[NewCensoredData()] var TempData = @[NewCensoredData()]
dbConn.select(TempData, "fhash = ?", param) 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()) RateLimiter[c.message.chat.id].insert(epochTime())
else: else:
RateLimiter[c.message.chat.id] = @[epochTime()] 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 # UnBan Handler
proc unbanHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} = 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" res.id = "1"
if not dbConn.exists(CensoredData, "fhash = ?",u.query): if not dbConn.exists(CensoredData, "fhash = ?",u.query):
res.title = "Media Not Found" 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: else:
dbConn.select(TempData, "fhash = ?", u.query) dbConn.select(TempData, "fhash = ?", u.query)
if len(TempData) > 1: if len(TempData) > 1:
@ -187,7 +196,14 @@ proc inlineHandler(b: Telebot, u: InlineQuery): Future[bool]{.async.} =
elif len(TempData) == 1: elif len(TempData) == 1:
ftype = TempData[0].ftype ftype = TempData[0].ftype
res.title = "Censored " & capitalizeAscii(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) results.add(res)
discard await b.answerInlineQuery(u.id, results) discard await b.answerInlineQuery(u.id, results)
@ -239,7 +255,16 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
insert CensoredRow insert CensoredRow
var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash)) var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash))
let replymark = newInlineKeyboardMarkup(@[replybutton]) 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: else:
let filehash = GroupMedia[parseInt(response.mediaGroupId.get)] let filehash = GroupMedia[parseInt(response.mediaGroupId.get)]
var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption) var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption)
@ -253,7 +278,16 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
insert CensoredRow insert CensoredRow
var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash)) var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash))
let replymark = newInlineKeyboardMarkup(@[replybutton]) 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() OldDataCleanup()
when isMainModule: when isMainModule: