async def set_flood(client, message): if len(message.command) == 2: input_str = message.command[1] try: sql.set_flood(message.chat.id, input_str) CHAT_FLOOD = sql.__load_flood_settings() await message.edit_text( "Antiflood updated to {} in the current chat".format(input_str) ) except Exception as e: # pylint:disable=C0103,W0703 await message.edit_text(str(e))
async def set_flood(_, message): """ /setflood command """ is_admin = await admin_check(message) if not is_admin: return if len(message.command) == 2: input_str = message.command[1] try: sql.set_flood(message.chat.id, input_str) global CHAT_FLOOD CHAT_FLOOD = sql.__load_flood_settings() await message.reply_text( "Antiflood updated to {} in the current chat".format(input_str)) except Exception as e: # pylint:disable=C0103,W0703 await message.reply_text(str(e))
"""Set Antiflood Syntax: .setflood""" import asyncio from pyrogram import (Client, filters) from pyrogram.types import (ChatPermissions) from pyrobot import (COMMAND_HAND_LER, DB_URI) from pyrobot.helper_functions.admin_check import admin_check from pyrobot.helper_functions.cust_p_filters import f_onw_fliter if DB_URI is not None: import pyrobot.helper_functions.sql_helpers.antiflood_sql as sql CHAT_FLOOD = sql.__load_flood_settings() @Client.on_message(filters.incoming, group=1) async def check_flood(client, message): """ check all messages """ if DB_URI is None: return # if not CHAT_FLOOD: return if not str(message.chat.id) in CHAT_FLOOD: return is_admin = await admin_check(message) if is_admin: return should_ban = sql.update_flood(message.chat.id, message.from_user.id) if not should_ban: return try: