Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def cmd_IRC2chan(command):
    """
    @irc2chan - link irc to ingame channel

    Usage:    
      @irc2chan <#IRCchannel> <local channel>

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

    """
    source_object = command.source_object
    if not settings.IRC_ENABLED:
        s = """IRC 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: @irc2chan IRCchannel channel")
        return
    irc_channel, channel = args.split()
    if irc_channel not in [o.factory.channel for o in IRC_CHANNELS]:
        source_object.emit_to("IRC channel '%s' not found." % irc_channel)
        return
    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 = IRCChannelMapping.objects.filter(channel__name=channel)
    if mapping:
        mapping = mapping[0]
        outstring = "Replacing %s. New " % mapping
    else:
        mapping = IRCChannelMapping()
    
    mapping.irc_server_name = settings.IRC_NETWORK
    mapping.irc_channel_name = irc_channel   
    mapping.channel = chanobj
    mapping.save()
    outstring += "Mapping set: %s." % mapping    
    source_object.emit_to(outstring)