Exemple #1
0
async def kk(event):
    global guy
    global lad
    guy = 0
    lad = 0
    if event.is_private:
        return await event.reply("This command is group specific")
    today = str(dt()[0])
    tomorrow = str(dt_tom())
    chat_id = event.chat_id
    is_selected = await get_couple(chat_id, today)
    if not is_selected:
        list_of_users = []
        async for i in tbot.iter_participants(chat_id):
            list_of_users.append(i.id)
        if len(list_of_users) < 2:
            await event.reply("Not enough users")
            return
        c1_id = random.choice(list_of_users)
        c2_id = random.choice(list_of_users)
        while c1_id == c2_id:
            c1_id = random.choice(list_of_users)
        arg = await tbot.get_entity(int(c2_id))
        c1_mention = arg.first_name
        gra = await tbot.get_entity(int(c1_id))
        c2_mention = gra.first_name
        couple_selection_message = f"""**Couple of the day:**
[{c1_mention}](tg://user?id={c2_id}) + [{c2_mention}](tg://user?id={c1_id}) = ❤️

__New couple of the day may be chosen at 12AM {tomorrow}__"""
        await tbot.send_message(event.chat_id, couple_selection_message)
        couple = {"c1_id": c1_id, "c2_id": c2_id}
        await save_couple(chat_id, today, couple)
    elif is_selected:
        c1_id = int(is_selected['c1_id'])
        c2_id = int(is_selected['c2_id'])
        try:
            gra = await tbot.get_entity(int(c1_id))
            c1_name = gra.first_name
        except:
            c1_name = c1_id
        try:
            arg = await tbot.get_entity(int(c2_id))
            c2_name = arg.first_name
        except:
            c2_name = c2_id
        couple_selection_message = f"""Couple of the day:
[{c1_name}](tg://user?id={c1_id}) + [{c2_name}](tg://user?id={c2_id}) = ❤️


__New couple of the day may be chosen at 12AM {tomorrow}__"""
        buttons = [
            Button.inline('Gey', data='ghei'),
            Button.inline('Lesbo👩‍❤️‍💋‍👩', data='leb')
        ]
        await tbot.send_message(event.chat_id,
                                couple_selection_message,
                                buttons=buttons)
Exemple #2
0
async def _(event):
    if event.fwd_from:
        return

    if event.is_group:
        if not await can_ban_users(message=event):
            return
    else:
        return

    # Here laying the sanity check
    chat = await event.get_chat()
    admin = chat.admin_rights.ban_users
    creator = chat.creator

    # Well
    if not creator:
        await event.reply("`I don't have enough permissions!`")
        return

    c = 0
    KICK_RIGHTS = ChatBannedRights(until_date=None, view_messages=True)
    done = await event.reply("Working ...")
    async for i in tbot.iter_participants(event.chat_id):

        if isinstance(i.status, UserStatusLastMonth):
            status = await tbot(EditBannedRequest(event.chat_id, i, KICK_RIGHTS))
            if not status:
                return
            c = c + 1

        if isinstance(i.status, UserStatusLastWeek):
            status = await tbot(EditBannedRequest(event.chat_id, i, KICK_RIGHTS))
            if not status:
                return
            c = c + 1

    if c == 0:
        await done.edit("Got no one to kick.")
        return

    required_string = "Successfully Kicked **{}** users"
    await event.reply(required_string.format(c))
Exemple #3
0
async def _(event):
    if not event.is_group:
        return
    if event.is_group:
        if not await can_ban_users(message=event):
            return

    # Here laying the sanity check
    chat = await event.get_chat()
    admin = chat.admin_rights.ban_users
    creator = chat.creator

    # Well
    if not admin and not creator:
        await event.reply("`I don't have enough permissions!`")
        return

    done = await event.reply("Working ...")
    p = 0
    async for i in tbot.iter_participants(
        event.chat_id, filter=ChannelParticipantsBanned, aggressive=True
    ):
        rights = ChatBannedRights(
            until_date=0,
            send_messages=False,
        )
        try:
            await tbot(functions.channels.EditBannedRequest(event.chat_id, i, rights))
        except FloodWaitError as ex:
            logger.warn("sleeping for {} seconds".format(ex.seconds))
            sleep(ex.seconds)
        except Exception as ex:
            await event.reply(str(ex))
        else:
            p += 1

    if p == 0:
        await done.edit("No one is muted in this chat")
        return
    required_string = "Successfully unmuted **{}** users"
    await event.reply(required_string.format(p))
Exemple #4
0
async def get_users(show):
    if not show.is_group:
        return
    if show.is_group:
        if not await is_register_admin(show.input_chat, show.sender_id):
            return
    info = await tbot.get_entity(show.chat_id)
    title = info.title if info.title else "this chat"
    mentions = "Users in {}: \n".format(title)
    async for user in tbot.iter_participants(show.chat_id):
        if not user.deleted:
            mentions += f"\n[{user.first_name}](tg://user?id={user.id}) {user.id}"
        else:
            mentions += f"\nDeleted Account {user.id}"
    file = open("userslist.txt", "w+")
    file.write(mentions)
    file.close()
    await tbot.send_file(
        show.chat_id,
        "userslist.txt",
        caption="Users in {}".format(title),
        reply_to=show.id,
    )
    os.remove("userslist.txt")
Exemple #5
0
async def get_admin(show):
    if show.is_group:
      if not show.sender_id == OWNER_ID:
        if not await is_register_admin(show.input_chat, show.sender_id):
            return
    else:
        return
    info = await tbot.get_entity(show.chat_id)
    title = info.title if info.title else "this chat"
    mentions = f"<b>Admins in {title}:</b> \n"
    try:
        async for user in tbot.iter_participants(
            show.chat_id, filter=ChannelParticipantsAdmins
        ):
            if not user.deleted:
                link_unf = '•<a href="tg://user?id={}">{}</a>'
                link = link_unf.format(user.id, user.first_name)
                userid = f"<code>{user.id}</code>"
                mentions += f"\n{link}"
            else:
                mentions += f"\nDeleted Account <code>{user.id}</code>"
    except ChatAdminRequiredError as err:
        mentions += " " + str(err) + "\n"
    await show.reply(mentions, parse_mode="html")
Exemple #6
0
async def rm_deletedacc(show):
    """ For .delusers command, list all the ghost/deleted accounts in a chat. """
    con = show.pattern_match.group(1).lower()
    del_u = 0
    del_status = "`No deleted accounts found, Group is cleaned as Hell`"

    if not show.is_group:
        return

    if show.is_group:
        if not await can_ban_users(message=show):
            return

    # Here laying the sanity check
    chat = await show.get_chat()
    admin = chat.admin_rights.ban_users
    creator = chat.creator

    # Well
    if not admin and not creator:
        await show.reply("`I don't have enough permissions!`")
        return

    if con != "clean":
        await show.reply("`Searching for zombie accounts...`")
        async for user in tbot.iter_participants(show.chat_id):
            if user.deleted:
                del_u += 1

        if del_u > 0:
            del_status = f"Found **{del_u}** deleted account(s) in this group,\
            \nclean them by using `/zombies clean`"

        await show.reply(del_status)
        return

    await show.reply("`Kicking deleted accounts...`")
    del_u = 0
    del_a = 0

    async for user in tbot.iter_participants(show.chat_id):
        if user.deleted:
            try:
                await tbot(EditBannedRequest(show.chat_id, user.id, BANNED_RIGHTS))
            except ChatAdminRequiredError:
                await show.reply("`I don't have ban rights in this group`")
                return
            except UserAdminInvalidError:
                del_u -= 1
                del_a += 1
            await tbot(EditBannedRequest(show.chat_id, user.id, UNBAN_RIGHTS))
            del_u += 1

    if del_u > 0:
        del_status = f"Cleaned **{del_u}** deleted account(s)"

    if del_a > 0:
        del_status = f"Cleaned **{del_u}** deleted account(s) \
        \n**{del_a}** deleted admin accounts are not removed"

    await show.reply(del_status)