예제 #1
0
파일: imc2.py 프로젝트: abbacode/avaloria
def cmd_IMC2chan(command):
    """
    @imc2chan

    Usage:
      @imc2chan <IMCServer> : <IMCchannel> <channel>

    Links an IMC channel to an existing evennia
    channel. You can link as many existing
    evennia channels as you like to the
    IMC channel this way. Running the command with an
    existing mapping will re-map the channels.

    Use 'imcchanlist' to get a list of IMC channels and
    servers. Note that both are case sensitive. 
    """
    source_object = command.source_object
    if not settings.IMC2_ENABLED:
        s = """IMC is not enabled. You need to activate it in game/settings.py."""
        source_object.emit_to(s)
        return
    args = command.command_argument
    if not args or len(args.split()) != 2 :
        source_object.emit_to("Usage: @imc2chan IMCServer:IMCchannel channel")
        return
    #identify the server-channel pair
    imcdata, channel = args.split()
    if not ":" in imcdata:
        source_object.emit_to("You need to supply an IMC Server:Channel pair.")
        return
    imclist = IMC2_CHANLIST.get_channel_list()
    imc_channels = filter(lambda c: c.name == imcdata, imclist)    
    if not imc_channels:
        source_object.emit_to("IMC server and channel '%s' not found." % imcdata)
        return
    else:
        imc_server_name, imc_channel_name = imcdata.split(":")
        
    #find evennia channel
    try:
        chanobj = comsys.get_cobj_from_name(channel)    
    except CommChannel.DoesNotExist:
        source_object.emit_to("Local channel '%s' not found (use real name, not alias)." % channel)
        return
       
    #create the mapping.
    outstring = ""
    mapping = IMC2ChannelMapping.objects.filter(channel__name=channel)
    if mapping:
        mapping = mapping[0]
        outstring = "Replacing %s. New " % mapping
    else:
        mapping = IMC2ChannelMapping()
    
    mapping.imc2_server_name = imc_server_name 
    mapping.imc2_channel_name = imc_channel_name
    mapping.channel = chanobj
    mapping.save()
    outstring += "Mapping set: %s." % mapping    
    source_object.emit_to(outstring)
예제 #2
0
파일: imc2.py 프로젝트: abbacode/avaloria
def cmd_imcchanlist(command):
    """
    imcchanlist

    Usage:
      imcchanlist
      
    Shows the list of cached channels from the IMC2 Channel list.
    """
    source_object = command.source_object
    
    retval = 'Channels on %s\n\r' % imc2_conn.IMC2_PROTOCOL_INSTANCE.network_name
    
    retval += ' Full Name          Name       Owner           Perm    Policy\n\r'
    retval += ' ---------          ----       -----           ----    ------\n\r'
    for channel in IMC2_CHANLIST.get_channel_list():
        retval += ' %-18s %-10s %-15s %-7s %s\n\r' % (channel.name, 
                                                      channel.localname,
                                                      channel.owner, 
                                                      channel.level,
                                                      channel.policy)
    retval += '%s channels found.' % len(IMC2_CHANLIST.chan_list)
    source_object.emit_to(retval)