Example #1
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat
    user = update.effective_user
    msg = update.effective_message

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text(tld(chat.id, 'warns_strength_on'))
            return tld(chat.id, 'warns_strength_on_log_channel').format(
                html.escape(chat.title), mention_html(user.id,
                                                      user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text(tld(chat.id, 'warns_strength_off'))
            return tld(chat.id, 'warns_strength_off_log_channel').format(
                html.escape(chat.title), mention_html(user.id,
                                                      user.first_name))

        else:
            msg.reply_text(tld(chat.id, 'warns_strength_invalid_arg'))
    else:
        soft_warn = sql.get_soft_warn(chat.id)
        if soft_warn:
            msg.reply_text(tld(chat.id, 'warns_strength_off'),
                           parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text(tld(chat.id, 'warns_strength_on'),
                           parse_mode=ParseMode.MARKDOWN)
    return ""
Example #2
0
def set_warn_strength(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]

    if args:
        if args[0].lower() in ("on", "yes"):
            sql.set_warn_strength(chat.id, False)
            msg.reply_text("Too many warns will now result in a ban!")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has enabled strong warns. Users will be banned.".format(html.escape(chat.title),
                                                                            mention_html(user.id, user.first_name))

        elif args[0].lower() in ("off", "no"):
            sql.set_warn_strength(chat.id, True)
            msg.reply_text("Too many warns will now result in a kick! Users will be able to join again after.")
            return "<b>{}:</b>\n" \
                   "<b>Admin:</b> {}\n" \
                   "Has disabled strong warns. Users will only be kicked.".format(html.escape(chat.title),
                                                                                  mention_html(user.id,
                                                                                               user.first_name))

        else:
            msg.reply_text("I only understand on/yes/no/off!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)
        if soft_warn:
            msg.reply_text("Warns are currently set to *kick* users when they exceed the limits.",
                           parse_mode=ParseMode.MARKDOWN)
        else:
            msg.reply_text("Warns are currently set to *ban* users when they exceed the limits.",
                           parse_mode=ParseMode.MARKDOWN)
    return ""