|
@@ -383,40 +383,43 @@ async def ban_deleted_accounts(_, message):
|
|
|
@app.on_message(filters.command("warn") & ~filters.edited)
|
|
@app.on_message(filters.command("warn") & ~filters.edited)
|
|
|
@capture_err
|
|
@capture_err
|
|
|
async def warn_user(_, message):
|
|
async def warn_user(_, message):
|
|
|
-
|
|
|
|
|
- from_user_id = message.from_user.id
|
|
|
|
|
- chat_id = message.chat.id
|
|
|
|
|
- permissions = await member_permissions(chat_id, from_user_id)
|
|
|
|
|
- if "can_restrict_members" in permissions or from_user_id in SUDOERS:
|
|
|
|
|
- if message.reply_to_message:
|
|
|
|
|
- user_id = message.reply_to_message.from_user.id
|
|
|
|
|
- mention = message.reply_to_message.from_user.mention
|
|
|
|
|
- if user_id in SUDOERS:
|
|
|
|
|
- await message.reply_text("You Wanna Warn The Elevated One?")
|
|
|
|
|
- else:
|
|
|
|
|
- if user_id in await list_members(chat_id):
|
|
|
|
|
- warns = await get_warn(chat_id, await int_to_alpha(user_id))
|
|
|
|
|
- if warns:
|
|
|
|
|
- warns = warns['warns']
|
|
|
|
|
- else:
|
|
|
|
|
- warn = {"warns": 1}
|
|
|
|
|
- await add_warn(chat_id, await int_to_alpha(user_id), warn)
|
|
|
|
|
- await message.reply_text(f"Warned {mention} !, 1/3 warnings now.")
|
|
|
|
|
- return
|
|
|
|
|
- if warns >= 3:
|
|
|
|
|
- await message.chat.kick_member(user_id)
|
|
|
|
|
- await message.reply_text(f"Number of warns of {mention} exceeded, Banned!")
|
|
|
|
|
- await remove_warns(chat_id, await int_to_alpha(user_id))
|
|
|
|
|
- else:
|
|
|
|
|
- warn = {"warns": warns+1}
|
|
|
|
|
- await add_warn(chat_id, await int_to_alpha(user_id), warn)
|
|
|
|
|
- await message.reply_text(f"Warned {mention} !, {warns+1}/3 warnings now.")
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ from_user_id = message.from_user.id
|
|
|
|
|
+ chat_id = message.chat.id
|
|
|
|
|
+ permissions = await member_permissions(chat_id, from_user_id)
|
|
|
|
|
+ if "can_restrict_members" in permissions or from_user_id in SUDOERS:
|
|
|
|
|
+ if message.reply_to_message:
|
|
|
|
|
+ user_id = message.reply_to_message.from_user.id
|
|
|
|
|
+ mention = message.reply_to_message.from_user.mention
|
|
|
|
|
+ if user_id in SUDOERS:
|
|
|
|
|
+ await message.reply_text("You Wanna Warn The Elevated One?")
|
|
|
else:
|
|
else:
|
|
|
- await message.reply_text("This user isn't here.")
|
|
|
|
|
|
|
+ if user_id in await list_members(chat_id):
|
|
|
|
|
+ warns = await get_warn(chat_id, await int_to_alpha(user_id))
|
|
|
|
|
+ if warns:
|
|
|
|
|
+ warns = warns['warns']
|
|
|
|
|
+ else:
|
|
|
|
|
+ warn = {"warns": 1}
|
|
|
|
|
+ await add_warn(chat_id, await int_to_alpha(user_id), warn)
|
|
|
|
|
+ await message.reply_text(f"Warned {mention} !, 1/3 warnings now.")
|
|
|
|
|
+ return
|
|
|
|
|
+ if warns >= 3:
|
|
|
|
|
+ await message.chat.kick_member(user_id)
|
|
|
|
|
+ await message.reply_text(f"Number of warns of {mention} exceeded, Banned!")
|
|
|
|
|
+ await remove_warns(chat_id, await int_to_alpha(user_id))
|
|
|
|
|
+ else:
|
|
|
|
|
+ warn = {"warns": warns+1}
|
|
|
|
|
+ await add_warn(chat_id, await int_to_alpha(user_id), warn)
|
|
|
|
|
+ await message.reply_text(f"Warned {mention} !, {warns+1}/3 warnings now.")
|
|
|
|
|
+ else:
|
|
|
|
|
+ await message.reply_text("This user isn't here.")
|
|
|
|
|
+ else:
|
|
|
|
|
+ await message.reply_text("Reply to someone's message to warn him.")
|
|
|
else:
|
|
else:
|
|
|
- await message.reply_text("Reply to someone's message to warn him.")
|
|
|
|
|
- else:
|
|
|
|
|
- await message.reply_text("You don't have enough permissions.")
|
|
|
|
|
|
|
+ await message.reply_text("You don't have enough permissions.")
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ await message.reply_text(str(e))
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|