From b90725d35b0ebeeba3bc43856060f960a1357592 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Mon, 11 Apr 2022 15:24:22 +0530 Subject: [PATCH] Add an unban handler, helps unban mistakely auto-banned users Signed-off-by: baalajimaestro --- src/nim_censor_bot.nim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/nim_censor_bot.nim b/src/nim_censor_bot.nim index 537e537..22b6daa 100644 --- a/src/nim_censor_bot.nim +++ b/src/nim_censor_bot.nim @@ -125,7 +125,19 @@ proc startHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} = elif TempData[0].ftype == "sticker": discard await b.sendSticker(c.message.chat.id, TempData[0].fileid) -# Ban Handler +# UnBan Handler +proc unbanHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} = + if $c.message.chat.id in AdminID: + let user = c.params + if dbConn.exists(BannedUsers, "userid = ?", int64(parseInt(user))): + var TempData = @[NewBannedUsers()] + dbConn.select(TempData, "userid = ?", int64(parseInt(user))) + for i in TempData: + var e = i + dbConn.delete(e) + discard await b.sendMessage(c.message.chat.id, "Unbanned!") + +# ban Handler proc banHandler(b: Telebot, c: Command): Future[bool] {.gcsafe, async.} = if $c.message.chat.id in AdminID: let user = c.params @@ -208,4 +220,5 @@ discard waitFor bot.setMyCommands(commands) bot.onUpdate(updateHandler) bot.onCommand("start", startHandler) bot.onCommand("ban", banHandler) +bot.onCommand("unban", unbanHandler) bot.poll(timeout=300)