Пример #1
0
async def _(event):
    input_str = event.pattern_match.group(1)
    event = await edit_or_reply(event, "flood ayarlarını güncelleme!")
    try:
        sql.set_flood(event.chat_id, input_str)
        sql.__load_flood_settings()
        await event.edit("Antiflood, mevcut sohbette {} olarak güncellendi".format(input_str))
    except Exception as e:  # pylint:disable=C0103,W0703
        await event.edit(str(e))
Пример #2
0
async def _(event):
    input_str = event.pattern_match.group(1)
    event = await edit_or_reply(event, "updating flood settings!")
    try:
        sql.set_flood(event.chat_id, input_str)
        sql.__load_flood_settings()
        await event.edit(
            "Antiflood updated to {} in the current chat".format(input_str))
    except Exception as e:  # pylint:disable=C0103,W0703
        await event.edit(str(e))
Пример #3
0
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    event = await edit_or_reply(event, "updating flood settings!")
    try:
        sql.set_flood(event.chat_id, input_str)
        sql.__load_flood_settings()
        await event.edit(
            "Antiflood updated untuk {} didalam ruang chat init".format(
                input_str))
    except Exception as e:  # pylint:disable=C0103,W0703
        await event.edit(str(e))
Пример #4
0
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    try:
        sql.set_flood(event.chat_id, input_str)
        CHAT_FLOOD = sql.__load_flood_settings()
        await event.edit("Antiflood updated to {} in the current chat".format(input_str))
    except Exception as e:  # pylint:disable=C0103,W0703
        await event.edit(str(e))
Пример #5
0
import asyncio

from telethon.tl.functions.channels import EditBannedRequest
from telethon.tl.types import ChatBannedRights

import userbot.plugins.sql_helper.antiflood_sql as sql

from .. import CMD_HELP
from ..utils import admin_cmd, edit_or_reply, sudo_cmd

CHAT_FLOOD = sql.__load_flood_settings()
# warn mode for anti flood
ANTI_FLOOD_WARN_MODE = ChatBannedRights(until_date=None,
                                        view_messages=None,
                                        send_messages=True)


@borg.on(admin_cmd(incoming=True))
async def _(event):
    if not CHAT_FLOOD:
        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