示例#1
0
def get_ban_arguments(connection, args):
    """
    Parses duration and reason from arguments.
    It handles duration in two ways: interger mintues and human-friendly duration.
    It also handles cases where duration or reason are none.
    Note: It returns duration in seconds.
    """
    default_duration = connection.protocol.default_ban_time
    reason = None
    if len(args) < 1:
        return default_duration, reason
    if len(args) > 1:
        reason = join_arguments(args[1:])
    if args[0] == "perma":
        return None, reason

    if args[0].isdigit():  # all digits == duration in minutes
        duration = int(args[0]) * 60
    elif has_digits(args[0]):  # if it contains some digits maybe duration?
        duration = timeparse(args[0])
        if not duration:
            raise ValueError("Invalid duration")
    else:  # maybe just one long reason
        duration = default_duration
        reason = join_arguments(args[:])
    return duration, reason
示例#2
0
def wban(connection, value, *arg):
    """
    Ban a given player for one week
    /wban <player> [reason]
    """
    duration = timeparse("1week")
    reason = join_arguments(arg)
    player = get_player(connection.protocol, value)
    player.ban(reason, duration)
示例#3
0
def hban(connection, value, *arg):
    """
    Ban a given player for an hour
    /hban <player> [reason]
    """
    duration = timeparse("1hour")
    reason = join_arguments(arg)
    player = get_player(connection.protocol, value)
    player.ban(reason, duration)
示例#4
0
def cast_duration(d) -> int:
    """
    casts duration(1min, 1hr) into seconds.
    If input is an int it returns that unmodified.
    """
    if isinstance(d, int):
        return d
    if not isinstance(d, str):
        raise ValueError("Invalid type")
    seconds = timeparse(d)
    if seconds is None:
        raise ValueError("Invalid duration")
    return seconds
示例#5
0
DISABLED, KICK, BAN, WARN_ADMIN = range(4)

# This controls which detection methods are enabled. If a player is detected
# using one of these methods, the given action is performed
HEADSHOT_SNAP = WARN_ADMIN
HIT_PERCENT = WARN_ADMIN
KILLS_IN_TIME = WARN_ADMIN
MULTIPLE_BULLETS = WARN_ADMIN

# Minimum amount of time that must pass between admin warnings that are
# triggered by the same detection method. Time is in seconds.
WARN_INTERVAL_MINIMUM = 300

# These controls are only used if banning is enabled
# Time is given in minutes. Set to 0 for a permaban
HEADSHOT_SNAP_BAN_DURATION = timeparse("23hours")
HIT_PERCENT_BAN_DURATION = timeparse("1day")
KILLS_IN_TIME_BAN_DURATION = timeparse("2day")
MULTIPLE_BULLETS_BAN_DURATION = timeparse("1week")

# If more than or equal to this number of weapon hit packets are received
# from the client in half the weapon delay time, then an aimbot is detected.
# This method of detection should have 100% detection and no false positives
# with the current aimbot.
# Note that the current aimbot does not modify the number of bullets
# of the shotgun, so this method will not work if the player uses a shotgun.
# These values may need to be changed if an update to the aimbot is released.
RIFLE_MULTIPLE_BULLETS_MAX = 8
SMG_MULTIPLE_BULLETS_MAX = 8

# The minimum number of near misses + hits that are fired before kicking,