Source code command to make the user clear on the bot source

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-04-17 20:03:31 +05:30
parent af6d4d68ab
commit 010c834aac
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -96,7 +96,7 @@ 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 messages could then be forwarded to any chat for them to view") 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!")
@ -125,6 +125,17 @@ proc startHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} =
elif TempData[0].ftype == "sticker": elif TempData[0].ftype == "sticker":
discard await b.sendSticker(c.message.chat.id, TempData[0].fileid) discard await b.sendSticker(c.message.chat.id, TempData[0].fileid)
# Give them source url
proc sourceHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} =
ManageRateLimit()
if not dbConn.exists(BannedUsers, "userid = ?", c.message.chat.id):
# Update rate-limit counter
if RateLimiter.contains(c.message.chat.id):
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)
# UnBan Handler # UnBan Handler
proc unbanHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} = proc unbanHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} =
if $c.message.chat.id in AdminID: if $c.message.chat.id in AdminID:
@ -240,7 +251,8 @@ when isMainModule:
echo "*********************" echo "*********************"
var commands = @[ var commands = @[
BotCommand(command: "start" , description: "Start the bot!") BotCommand(command: "start" , description: "Start the bot!"),
BotCommand(command: "source" , description: "Info about bot source")
] ]
discard waitFor bot.setMyCommands(commands) discard waitFor bot.setMyCommands(commands)
@ -248,6 +260,7 @@ when isMainModule:
bot.onCommand("start", startHandler) bot.onCommand("start", startHandler)
bot.onCommand("ban", banHandler) bot.onCommand("ban", banHandler)
bot.onCommand("unban", unbanHandler) bot.onCommand("unban", unbanHandler)
bot.onCommand("source", sourceHandler)
bot.onInlineQuery(inlineHandler) bot.onInlineQuery(inlineHandler)
if getEnv("HOOK_DOMAIN") != "": if getEnv("HOOK_DOMAIN") != "":
bot.startWebhook(getEnv("HOOK_SECRET"), getEnv("HOOK_DOMAIN") & "/" & getEnv("HOOK_SECRET")) bot.startWebhook(getEnv("HOOK_SECRET"), getEnv("HOOK_DOMAIN") & "/" & getEnv("HOOK_SECRET"))