async def _(event): # logger.info(CHAT_FLOOD) if not CHAT_FLOOD: return admin_c = await is_admin(event.chat_id, event.message.from_id) if admin_c: return if str(event.chat_id) not in CHAT_FLOOD: return should_ban = sql.update_flood(event.chat_id, event.message.from_id) if not should_ban: return try: await event.client( EditBannedRequest(event.chat_id, event.message.from_id, ANTI_FLOOD_WARN_MODE)) except Exception as e: # pylint:disable=C0103,W0703 no_admin_privilege_message = await event.client.send_message( entity=event.chat_id, message="""**Automatic AntiFlooder** @admin [User](tg://user?id={}) is flooding this chat. `{}`""".format(event.message.from_id, str(e)), reply_to=event.message.id) await asyncio.sleep(10) await no_admin_privilege_message.edit( "Sadly u don't have admin privilege") else: await event.client.send_message(entity=event.chat_id, message="""**Automatic AntiFlooder** [User](tg://user?id={}) has been automatically restricted because he reached the defined flood limit.""".format(event.message.from_id), reply_to=event.message.id)
async def _(event): # logger.info(CHAT_FLOOD) if not CHAT_FLOOD: return admin_c = await is_admin(event.chat_id, event.message.from_id) if admin_c: return if not (str(event.chat_id) in CHAT_FLOOD): return should_ban = sql.update_flood(event.chat_id, event.message.from_id) if not should_ban: return try: await event.client( EditBannedRequest( event.chat_id, event.message.from_id, ANTI_FLOOD_WARN_MODE ) ) except Exception as e: # pylint:disable=C0103,W0703 no_admin_privilege_message = await event.client.send_message( entity=event.chat_id, message="""**Automatic AntiFlooder** [User](tg://user?id={}) Membanjiri obrolan. `{}`""".format( event.message.from_id, str(e) ), reply_to=event.message.id, ) await asyncio.sleep(10) await no_admin_privilege_message.edit("Sadly u don't have admin privilege") else: await event.client.send_message( entity=event.chat_id, message="""**Automatic AntiFlooder** [User](tg://user?id={}) Membanjiri obrolan. **Aksi:** Saya membisukan dia 🔇""".format( event.message.from_id ), reply_to=event.message.id, )
async def _(event): # logger.info(CHAT_FLOOD) if not CHAT_FLOOD: return admin_c = await is_admin(event.chat_id, event.message.from_id) if admin_c: return if not (str(event.chat_id) in CHAT_FLOOD): return should_ban = sql.update_flood(event.chat_id, event.message.from_id) if not should_ban: return try: await event.client( EditBannedRequest(event.chat_id, event.message.from_id, ANTI_FLOOD_WARN_MODE)) except Exception as e: # pylint:disable=C0103,W0703 no_admin_privilege_message = await event.client.send_message( entity=event.chat_id, message="""**Anti Banjir Otomatis** @admin [User](tg://user?id={}) membanjiri obrolan ini `{}`""".format(event.message.from_id, str(e)), reply_to=event.message.id, ) await asyncio.sleep(10) await no_admin_privilege_message.edit( "Sayangnya kamu tidak punya admin hak istimewa") else: await event.client.send_message( entity=event.chat_id, message="""**Anti Banjir Otomatis** [User](tg://user?id={}) telah dibatasi secara otomatis karena dia mencapai batas banjir yang ditentukan""".format( event.message.from_id), reply_to=event.message.id, )