Exemple #1
0
def global_chat(connection, value=None):
    """
    Enable or disable global chat
    /globalchat [on|off]
    Toggles if no arguments are given
    """
    enabled = get_truthy(value)
    if enabled is True:
        connection.protocol.global_chat = True
    elif enabled is False:
        connection.protocol.global_chat = False
    else:
        connection.protocol.global_chat = not connection.protocol.global_chat

    connection.protocol.send_chat(
        'Global chat %s' %
        ('enabled' if connection.protocol.global_chat else 'disabled'),
        irc=True)
Exemple #2
0
def set_balance(connection, value):
    """
    Turn automatic balancing on or off
    /setbalance <on|off>
    """
    should_balance = get_truthy(value)
    if should_balance is None:
        raise CommandError()

    protocol = connection.protocol
    protocol.balanced_teams = should_balance

    if should_balance:
        protocol.send_chat('now balancing teams')
        connection.protocol.irc_say('* %s turned on balanced teams' %
                                    connection.name)
    else:
        protocol.send_chat('now no longer balancing teams')
        connection.protocol.irc_say('* %s turned off balanced teams' %
                                    connection.name)