Exemple #1
0
async def get_invalid_gban(c: Alita, _, remove: bool = False):
    banned = gban_db.get_gban_list()
    ungbanned_users = 0
    ungban_list = []

    for user in banned:
        user_id = user["user_id"]
        await sleep(0.1)
        try:
            await c.get_users(user_id)
        except BadRequest:
            ungbanned_users += 1
            ungban_list.append(user_id)
        except RPCError:
            pass

    if remove:
        for user_id in ungban_list:
            try:
                await sleep(0.1)
                gban_db.ungban_user(user_id)
            except RPCError:
                pass

    return ungbanned_users
Exemple #2
0
async def gban_list(c: Alita, m: Message):
    banned_users = db.get_gban_list()

    if not banned_users:
        await m.reply_text("There aren't any gbanned users...!")
        return

    banfile = "Banned geys!.\n"
    for user in banned_users:
        banfile += "[x] {} - {}\n".format(user["name"], user["user_id"])
        if user["reason"]:
            banfile += "Reason: {}\n".format(user["reason"])

    with BytesIO(str.encode(banfile)) as output:
        output.name = "gbanlist.txt"
        await m.reply_document(
            document=output,
            caption="Here is the list of currently gbanned users.",
        )

        return
async def gban_list(_: Alita, m: Message):
    banned_users = db.get_gban_list()

    if not banned_users:
        await m.reply_text("There aren't any gbanned users...!")
        return

    banfile = "Banned geys!.\n"
    for user in banned_users:
        banfile += "[x] {} - {}\n".format(user["name"], user["user_id"])
        if user["reason"]:
            banfile += "Reason: {}\n".format(user["reason"])

    with open("gbanlist.txt", "w+") as f:
        f.write(banfile)
        await m.reply_document(
            document=f,
            caption="Here is the list of currently gbanned users.",
        )

        return