Exemple #1
0
def start_votekick(connection, *args):
    protocol = connection.protocol
    if connection not in protocol.players:
        raise KeyError()
    player = connection

    if not protocol.votekick_enabled:
        return S_VOTEKICKING_DISABLED
    if not player.votekick_enabled:
        return S_VOTEKICK_DISALLOWED

    if not args:
        if protocol.votekick:
            # player requested votekick info
            protocol.votekick.send_chat_update(player)
            return
        raise ValueError()

    value = args[0]
    victim = get_player(protocol, value)
    reason = join_arguments(args[1:])

    try:
        # attempt to start votekick
        votekick = Votekick.start(player, victim, reason)
        protocol.votekick = votekick
    except VotekickFailure as err:
        return str(err)
Exemple #2
0
def pban(connection, value, *arg):
    """
    Ban a given player permanently
    /pban <player> [reason]
    """
    duration = 0
    reason = join_arguments(arg)
    player = get_player(connection.protocol, value)
    player.ban(reason, duration)
Exemple #3
0
def wban(connection, value, *arg):
    """
    Ban a given player for one week
    /wban <player> [reason]
    """
    duration = 10080
    reason = join_arguments(arg)
    player = get_player(connection.protocol, value)
    player.ban(reason, duration)
Exemple #4
0
def hban(connection, value, *arg):
    """
    Ban a given player for an hour
    /hban <player> [reason]
    """
    duration = 60
    reason = join_arguments(arg)
    player = get_player(connection.protocol, value)
    player.ban(reason, duration)
Exemple #5
0
def kick(connection, value, *arg):
    """
    Kick a given player
    /kick <player>
    Player is the #ID of the player, or an unique part of their name
    """
    reason = join_arguments(arg)
    player = get_player(connection.protocol, value)
    player.kick(reason)
Exemple #6
0
def pm(connection, value, *arg):
    """
    Send a private message to a given player
    /pm <player> <message>
    """
    player = get_player(connection.protocol, value)
    message = join_arguments(arg)
    if len(message) == 0:
        return "Please specify your message"
    player.send_chat('PM from %s: %s' % (connection.name, message))
    return 'PM sent to %s' % player.name
Exemple #7
0
def server_name(connection, *arg):
    """
    Change the server name until it restarts
    /servername <new-name>
    Also affects the master list
    """
    name = join_arguments(arg)
    protocol = connection.protocol
    protocol.config['name'] = name
    protocol.update_format()
    message = "%s changed servername to '%s'" % (connection.name, name)
    print(message)
    connection.protocol.irc_say("* " + message)
    if connection in connection.protocol.players:
        return message
Exemple #8
0
def get_ban_arguments(connection, arg):
    duration = None
    if len(arg):
        try:
            duration = int(arg[0])
            arg = arg[1:]
        except (IndexError, ValueError):
            pass
    if duration is None:
        if len(arg) > 0 and arg[0] == "perma":
            arg = arg[1:]
        else:
            duration = connection.protocol.default_ban_time
    reason = join_arguments(arg)
    return duration, reason
Exemple #9
0
def timed_mute(connection, *args):
    protocol = connection.protocol
    if len(args) < 3:
        return '/tm <nick> <time> <reason>'

    nick = args[0]
    time = int(args[1])
    reason = join_arguments(args[2:])
    player = get_player(protocol, nick)

    if time < 0:
        raise ValueError()

    if not player.mute:
        TimedMute(player, time, reason)
    else:
        return '%s is already muted!' % nick
Exemple #10
0
def to_admin(connection, *arg):
    """
    Send a message to all admins currently online
    /admin <message>
    """
    protocol = connection.protocol
    message = join_arguments(arg)
    if not message:
        return "Enter a message you want to send, like /admin I'm stuck"
    prefix = '(TO ADMINS)'
    irc_relay = protocol.irc_relay
    if irc_relay:
        if irc_relay.factory.bot and irc_relay.factory.bot.colors:
            prefix = '\x0304' + prefix + '\x0f'
        irc_relay.send(prefix + ' <%s> %s' % (connection.name, message))
    for player in protocol.players.values():
        if player.admin and player is not connection:
            player.send_chat('To ADMINS from %s: %s' %
                             (connection.name, message))
    return 'Message sent to all admins currently online'