Example #1
0
async def ungbun(event):
    await event.edit("**Un-GBanning User**")
    sucess = 0
    bad = 0
    user, reason = await get_user_from_event(event)
    if not user.id:
        await event.edit("`Mention A User To Un-Gban`")
        return
    if user.id == bot.uid:
        await event.edit("**I Can't Un-Gban You Master :(**")
        return
    if not gban_sql.is_gbanned(user.id):
        await event.edit(
            "**This User Is Not Gbanned. No Point In Un-Gbanning !**")
        return
    gban_sql.ungban_user(user.id)
    chat_s = await get_all_admin_chats(event)
    len_s = len(chat_s)
    await event.edit(
        f"**Un-GBanning !** [{user.first_name}](tg://user?id={user.id}) **in {len_s} Chats!**"
    )
    for stark_s in chat_s:
        try:
            await event.client.edit_permissions(stark_s,
                                                user.id,
                                                view_messages=True)
            sucess += 1
        except:
            bad += 0
    await event.edit(
        f"**Un-GBanned !**[{user.first_name}](tg://user?id={user.id}) **in {len_s} Chats!**"
    )
Example #2
0
async def ungbun(event):
    if event.fwd_from:
        return
    await event.edit("**Un-GBanning User**")
    sucess = 0
    bad = 0
    o = await all_pro_s(Config, client2, client3, client4)
    stime = time.time()
    user, reason = await get_user_from_event(event)
    if not user.id:
        await event.edit("`Mention A User To Un-Gban`")
        return
    if user.id in o:
        await event.edit("**I Can't Un-Gban You Master :(**")
        return
    if not gban_sql.is_gbanned(user.id):
        await event.edit(
            "**This User Is Not Gbanned. No Point In Un-Gbanning !**")
        return
    gban_sql.ungban_user(user.id)
    chat_s = await get_all_admin_chats(event)
    if len(chat_s) == 0:
        await event.edit(
            "**You Need To Be Admin In Atleast 1 Group To Perform this Action**"
        )
        return
    len_s = len(chat_s)
    await event.edit(
        f"**Un-GBanning !** [{user.first_name}](tg://user?id={user.id}) **in {len_s} Chats!**"
    )
    for stark_s in chat_s:
        try:
            await event.client.edit_permissions(stark_s,
                                                user.id,
                                                view_messages=True)
            sucess += 1
        except:
            bad += 0
    etime = time.time()
    hmm_time = round(etime - stime)
    await event.edit(
        f"**Un-GBanned Successfully !** \n\n"
        f"**User :** [{user.first_name}](tg://user?id={user.id}) \n"
        f"**Affected Chats :** `{sucess}` \n"
        f"**Time Taken :** `{hmm_time}`")