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)