async def set_warn_strength(event): try: chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator args = event.pattern_match.group(1) except: return await event.reply("`Error`") if args: if args in ("ban"): sql.set_warn_strength(event.chat_id, False) await event.reply("Warn mode Set To Ban User.") return elif args in ("mute"): sql.set_warn_strength(event.chat_id, True) await event.reply("warn mode Set To Kick User.") return else: await event.reply("`Error usage !setwarnmode kick or mute`") else: limit, soft_warn = sql.get_warn_setting(event.chat_id) if soft_warn: await event.reply("I Am **muting** User's For Now.") else: await event.reply("I Am **Baning** User's For Now.") return ""
async def _(event): if event.fwd_from: return try: chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator warn_reason = event.pattern_match.group(1) reply_message = await event.get_reply_message() except: return await event.reply("`Sorry canot warn users here`") if not admin and not creator: return await event.reply("`I have to be admin to warn people.`") if await is_admin(event.chat_id, reply_message.sender.id): return await event.reply("`I'm not going to warn an admin!`") if reply_message.sender.id == 929138153: return await event.edit( "__HEY ME IS JAVES-3.0 THE TG USERBOT CRETED BY HIM__") limit, soft_warn = sql.get_warn_setting(event.chat_id) num_warns, reasons = sql.warn_user(reply_message.sender.id, event.chat_id, warn_reason) if num_warns >= limit: if soft_warn: reply = "{} warnings, <u><a href='tg://user?id={}'>user</a></u> has been muted!".format( limit, reply_message.sender.id) await event.client.edit_permissions(chat, reply_message.sender.id, until_date=None, send_messages=False) else: await event.client.edit_permissions(chat, reply_message.sender.id, until_date=None, view_messages=False) reply = "{} warnings, <u><a href='tg://user?id={}'>user</a></u> has been banned!".format( limit, reply_message.sender.id) else: reply = "<u><a href='tg://user?id={}'>user</a></u> has {}/{} warnings... watch out!".format( reply_message.sender.id, num_warns, limit) if warn_reason: reply += "\nReason for last warn:\n{}".format( html.escape(warn_reason)) # await event.reply(reply, parse_mode="html")
async def _(event): if event.fwd_from: return reply_message = await event.get_reply_message() result = sql.get_warns(reply_message.sender.id, event.chat_id) if result and result[0] != 0: num_warns, reasons = result limit, soft_warn = sql.get_warn_setting(event.chat_id) if reasons: text = "This user has {}/{} warnings, for the following reasons:".format( num_warns, limit) text += "\r\n" text += reasons await event.reply(text) else: await event.reply( "This user has {} / {} warning, but no reasons for any of them." .format(num_warns, limit)) else: await event.reply("This user hasn't got any warnings!")
async def set_warn_limit(event): try: chat = await event.get_chat() admin = chat.admin_rights creator = chat.creator input_str = event.pattern_match.group(1) except: return await event.reply("`Error`") if input_str: if int(input_str) < 3: await event.reply("`The minimum warn limit is 3!`") else: sql.set_warn_limit(event.chat_id, int(input_str)) await event.reply( "`Updated the warn limit to` {}".format(input_str)) return else: limit, soft_warn = sql.get_warn_setting(event.chat_id) await event.reply("`The current warn limit is {}`".format(limit)) return ""