From 82083fedf7dfea395385dcc0dcadfd4f1a2d23e1 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 17 Apr 2022 20:17:40 +0530 Subject: [PATCH] Split strings for readability Signed-off-by: baalajimaestro --- src/nim_censor_bot.nim | 48 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/nim_censor_bot.nim b/src/nim_censor_bot.nim index 1a240b7..9cc331b 100644 --- a/src/nim_censor_bot.nim +++ b/src/nim_censor_bot.nim @@ -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: