From b27f910362d05ecc117b1b0ed6791f3d250a1ba6 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 10 Apr 2022 23:30:15 +0530 Subject: [PATCH] Lock admin actions behind a env variable ADMIN_ID is comma-separated values of the user-ids of admins who will have access to /ban Signed-off-by: baalajimaestro --- src/nim_censor_bot.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/nim_censor_bot.nim b/src/nim_censor_bot.nim index 431cc7e..b718c8c 100644 --- a/src/nim_censor_bot.nim +++ b/src/nim_censor_bot.nim @@ -69,11 +69,12 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} = 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("/ban"): - let user = message.split(" ") - var BannedUser = NewBannedUsers(int64(parseInt(user[1])), epochTime(), "permanent") - with dbConn: - insert BannedUser - discard await b.sendMessage(response.chat.id, "Banned!") + if $response.chat.id in AdminID: + let user = message.split(" ") + var BannedUser = NewBannedUsers(int64(parseInt(user[1])), epochTime(), "permanent") + with dbConn: + insert BannedUser + discard await b.sendMessage(response.chat.id, "Banned!") elif message.contains("/start"): let deeplink = message.split(" ") if not dbConn.exists(CensoredData, "fhash = ?", deeplink[1]):