示例#1
0
async def _(event):
    if event.fwd_from:
        return
    input_chnnl = event.pattern_match.group(1)
    all_chnnl = get_all_chnnl()
    if input_chnnl == "all":
        for channelz in all_chnnl:
            rm_channel(channelz.chat_id)
        await edit_or_reply(event, "Fine. Cleared All Channel Database")
        return
    if input_chnnl == "":
        if event.is_channel and event.is_group:
            input_chnnl = event.chat_id
        else:
            await edit_or_reply(event, "Please Give Group / Channel ID")
            return
    if already_added(input_chnnl):
        rm_channel(input_chnnl)
        await edit_or_reply(
            event, f"Fine. I have Removed {input_chnnl} From DataBase.")
        await borg.send_message(loggy_grp, f"Removed {input_chnnl} From DB")
    elif not already_added(input_chnnl):
        await edit_or_reply(
            event,
            "Are You Sure? , You Haven't Added This Group / Channel To Database"
        )
示例#2
0
async def _(event):
    if event.fwd_from:
        return
    input_chnnl = event.pattern_match.group(1)
    sed = 0
    oks = 0
    if input_chnnl == "all":
        poppo = await friday.edit_or_reply(event,
                                           "`Adding All Channel TO DB.`")
        addall = [
            d.entity for d in await event.client.get_dialogs()
            if (d.is_group or d.is_channel)
        ]
        for i in addall:
            try:
                if i.broadcast:
                    if i.creator or i.admin_rights:
                        if already_added(i.id):
                            oks += 1
                        else:
                            add_chnnl_in_db(i.id)
                            sed += 1
            except BaseException:
                pass
        await poppo.edit(
            f"Process Completed. Added {sed} Channel To List. Failed {oks} Due to already Added !"
        )
        return
    elif input_chnnl == "":
        if event.is_channel and event.is_group:
            input_chnnl = event.chat_id
        else:
            await friday.edit_or_reply(event,
                                       "Please Give Group / Channel ID !")
            return
    if already_added(input_chnnl):
        await friday.edit_or_reply(event,
                                   "This Channel Already Found in Database.")
        return
    if not already_added(input_chnnl):
        add_chnnl_in_db(input_chnnl)
        M = f"Fine. I have Added {input_chnnl} To DataBase."
        Ml = f"Added {input_chnnl} To DB"
        await friday.edit_or_reply(event, M)
        await borg.send_message(loggy_grp, Ml)