예제 #1
0
def gbanlist(update, context):
    banned_users = sql.get_gban_list()

    if not banned_users:
        send_message(
            update.effective_message,
            tl(
                update.effective_message,
                "Tidak ada pengguna yang dilarang global! Anda lebih baik dari yang saya harapkan..."
            ))
        return

    banfile = tl(update.effective_message, 'Persetan orang-orang ini.\n')
    for user in banned_users:
        banfile += "[x] {} - {}\n".format(user["name"], user["user_id"])
        if user["reason"]:
            banfile += "Alasan: {}\n".format(user["reason"])

    with BytesIO(str.encode(banfile)) as output:
        output.name = "gbanlist.txt"
        update.effective_message.reply_document(
            document=output,
            filename="gbanlist.txt",
            caption=tl(
                update.effective_message,
                "Berikut adalah daftar pengguna yang saat ini dilarang secara global."
            ))
예제 #2
0
def gbanlist(update, context):
    banned_users = sql.get_gban_list()

    if not banned_users:
        send_message(
            update.effective_message,
            tl(
                update.effective_message,
                "There aren't any gbanned users! You're kinder than I expected..."
            ))
        return

    banfile = tl(update.effective_message, 'Screw these guys.\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"
        update.effective_message.reply_document(
            document=output,
            filename="gbanlist.txt",
            caption=tl(update.effective_message,
                       "Here is the list of currently gbanned users."))
예제 #3
0
def clear_gbans(update, context):
    banned = sql.get_gban_list()
    deleted = 0
    update.message.reply_text(
        "*Beginning to cleanup deleted users from global ban database...*\nThis process might take a while...",
        parse_mode=ParseMode.MARKDOWN)
    for user in banned:
        id = user["user_id"]
        time.sleep(0.1)  # Reduce floodwait
        try:
            context.bot.get_chat(id)
        except BadRequest:
            deleted += 1
            sql.ungban_user(id)
    update.message.reply_text("Done! {} deleted accounts were removed " \
    "from the gbanlist.".format(deleted), parse_mode=ParseMode.MARKDOWN)
예제 #4
0
def get_invalid_gban(bot: Bot, update: Update, remove: bool = False):
    banned = gban_sql.get_gban_list()
    ungbanned_users = 0
    ungban_list = []

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

    if not remove:
        return ungbanned_users
    else:
        for user_id in ungban_list:
            sleep(0.1)
            gban_sql.ungban_user(user_id)
        return ungbanned_users