Example #1
0
def bl_user(bot: Bot, update: Update, args):
    if update.effective_message.reply_to_message:
        user_id = str(update.effective_message.reply_to_message.from_user.id)
        reason = " ".join(args)
    else:
        user_id = args[0]
        reason = " ".join(args[1:])
    sql.blacklist_user(user_id, reason)
    update.effective_message.reply_text(
        "User has been blacklisted from using me!")
def bl_user(bot: Bot, update: Update, args: List[str]) -> str:
    message = update.effective_message
    user = update.effective_user

    user_id, reason = extract_user_and_text(message, args)

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

    if user_id == bot.id:
        message.reply_text(
            "Bagaimana saya bisa melakukan pekerjaan saya jika saya mengabaikan diri saya sendiri?"
        )
        return ""

    if user_id in BLACKLISTWHITELIST:
        message.reply_text("Tidak!\nMemperhatikan anda pekerjaan saya.")
        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

    sql.blacklist_user(user_id, reason)
    message.reply_text("Saya akan mengabaikan keberadaan pengguna ini!")
    log_message = (
        f"#BLACKLIST\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)}"
    )
    if reason:
        log_message += f"\n<b>Alasan:</b> {reason}"

    return log_message
def bl_user(update: Update, context: CallbackContext) -> str:
    message = update.effective_message
    user = update.effective_user
    bot, args = context.bot, context.args
    user_id, reason = extract_user_and_text(message, args)

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

    if user_id == bot.id:
        message.reply_text(
            "How am I supposed to do my work if I am ignoring myself?")
        return ""

    if int(user_id) in (820596651, 1734396873):
        message.reply_text("Huh, why would I blaklist Telegram kings?")
        return ""

    if user_id in BLACKLISTWHITELIST:
        message.reply_text("No!\nNoticing Nations is my job.")
        return ""

    try:
        target_user = bot.get_chat(user_id)
    except BadRequest as excp:
        if excp.message != 'User not found':
            raise
        message.reply_text("I can't seem to find this user.")
        return ''
    sql.blacklist_user(user_id, reason)
    message.reply_text("I shall ignore the existence of this user!")
    log_message = (
        f"#BLACKLIST\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)}")
    if reason:
        log_message += f"\n<b>Reason:</b> {reason}"

    return log_message
Example #4
0
def bl_user(bot: Bot, update: Update, args: List[str]) -> str:

    message = update.effective_message
    user = update.effective_user

    user_id, reason = extract_user_and_text(message, args)

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

    if user_id == bot.id:
        message.reply_text(
            "How am I supposed to do my work if I am ignoring myself?")
        return ""

    if user_id in BLACKLISTWHITELIST:
        message.reply_text("No!\nNoticing Disasters is my job.")
        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

    sql.blacklist_user(user_id, reason)
    message.reply_text("I shall ignore the existence of this user!")
    log_message = "#BLACKLIST" \
                  "\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))
    if reason:
        log_message += "\n<b>Reason:</b> {}".format(reason)

    return log_message