Esempio n. 1
0
def unbl_user(update: Update, context: CallbackContext) -> str:
    message = update.effective_message
    user = update.effective_user
    bot, args = context.bot, context.args
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("I doubt that's a user.")
        return ""

    if user_id == bot.id:
        message.reply_text("I always notice myself.")
        return ""

    try:
        target_user = bot.get_chat(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("I can't seem to find this user.")
            return ""
        raise

    if sql.is_user_blacklisted(user_id):

        sql.unblacklist_user(user_id)
        message.reply_text("*notices user*")
        log_message = (
            f"#UNBLACKLIST\n"
            f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
            f"<b>User:</b> {mention_html(target_user.id, target_user.first_name)}"
        )

        return log_message
    message.reply_text("I am not ignoring them at all though!")
    return ""
Esempio n. 2
0
def unbl_user(bot: Bot, update: Update, args):
    rep = update.effective_message
    msg = update.effective_message.reply_to_message
    if msg:
        user_id = str(msg.from_user.id)
    else:
        user_id = args[0]
    if sql.is_user_blacklisted(int(user_id)):
        sql.unblacklist_user(user_id)
        rep.reply_text("User removed from blacklist!")
    else:
        rep.reply_text("User isn't even blacklisted!")
def unbl_user(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user

    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("Saya ragu itu adalah pengguna.")
        return ""

    if user_id == bot.id:
        message.reply_text("Saya selalu memperhatikan diri saya sendiri.")
        return ""

    try:
        target_user = bot.get_chat(user_id)
    except BadRequest as excp:
        if excp.message == "Pengguna tidak ditemukan":
            message.reply_text(
                "Sepertinya saya tidak dapat menemukan pengguna ini.")
            return ""
        else:
            raise

    if sql.is_user_blacklisted(user_id):

        sql.unblacklist_user(user_id)
        message.reply_text("*notices user*")
        log_message = (
            f"#UNBLACKLIST\n"
            f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
            f"<b>Pengguna:</b> {mention_html(target_user.id, target_user.first_name)}"
        )

        return log_message

    else:
        message.reply_text("Saya tidak mengabaikan mereka sama sekali!")
        return ""
Esempio n. 4
0
def unbl_user(bot: Bot, update: Update, args: List[str]) -> str:

    message = update.effective_message
    user = update.effective_user

    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("I doubt that's a user.")
        return ""

    if user_id == bot.id:
        message.reply_text("I always notice myself.")
        return ""

    try:
        target_user = bot.get_chat(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            message.reply_text("I can't seem to find this user.")
            return ""
        else:
            raise

    if sql.is_user_blacklisted(user_id):

        sql.unblacklist_user(user_id)
        message.reply_text("*notices user*")
        log_message = "#UNBLACKLIST" \
                      "\n<b>Admin:</b> {}" \
                      "\n<b>User:</b> {}".format(mention_html(user.id, user.first_name),
                                                mention_html(target_user.id, target_user.first_name))

        return log_message

    else:
        message.reply_text("I am not ignoring them at all though!")
        return ""