Esempio n. 1
0
def set_warn_limit(bot: Bot, update: Update, args: List[str]) -> 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].isdigit():
            if int(args[0]) < 3:
                msg.reply_text("The minimum warn limit is 3!")
            else:
                sql.set_warn_limit(chat.id, int(args[0]))
                msg.reply_text("Updated the warn limit to {}".format(args[0]))
                return "<b>{}:</b>" \
                       "\n#SET_WARN_LIMIT" \
                       "\n<b>Admin:</b> {}" \
                       "\nSet the warn limit to <code>{}</code>".format(html.escape(chat.title),
                                                                        mention_html(user.id, user.first_name), args[0])
        else:
            msg.reply_text("Give me a number as an arg!")
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)

        msg.reply_text("The current warn limit is {}".format(limit))
    return ""
Esempio n. 2
0
def set_warn_limit(bot: Bot, update: Update, args: List[str]) -> str:
    chat = update.effective_chat
    user = update.effective_user
    msg = update.effective_message

    if args:
        if args[0].isdigit():
            if int(args[0]) < 1:
                msg.reply_text(tld(chat.id, 'warns_warnlimit_min_1'))
            else:
                sql.set_warn_limit(chat.id, int(args[0]))
                msg.reply_text(
                    tld(chat.id,
                        'warns_warnlimit_updated_success').format(args[0]))
                return tld(chat.id, 'warns_set_warn_limit_log_channel').format(
                    html.escape(chat.title),
                    mention_html(user.id, user.first_name), args[0])
        else:
            msg.reply_text(tld(chat.id, 'warns_warnlimit_invalid_arg'))
    else:
        limit, soft_warn = sql.get_warn_setting(chat.id)

        msg.reply_text(tld(chat.id, 'warns_warnlimit_current').format(limit))
    return ""