Add an unban handler, helps unban mistakely auto-banned users

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-04-11 15:24:22 +05:30
parent 11cbdcaced
commit b90725d35b
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -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)