Пример #1
0
def makeircconfig(type=None, opts=None, botname=None):
    """ make config file based on options. """
    if not opts: botname = botname or "default-irc"
    else:
        if not botname: botname = opts.name or "default-irc"
    botname = stripname(botname)
    cfg = Config('fleet' + os.sep + botname + os.sep + 'config')
    cfg.type = 'irc'
    cfg.botname = botname
    if not opts:
        cfg.password = ""
        cfg.ssl = False
        cfg.port = 6667
        cfg.server = "localhost"
        cfg.owner = []
        cfg.ipv6 = False
        return cfg
    if opts.password: cfg.password = opts.password
    if opts.ssl: cfg.ssl = True
    if opts.nossl: cfg.ssl = False
    if opts.port: cfg.port = opts.port
    else: cfg.port = 6667
    if opts.server: cfg.server = opts.server
    else: cfg.server = cfg.server or "localhost"
    if not cfg.owner: cfg.owner = []
    if opts.owner and opts.owner not in cfg.owner: cfg.owner.append(opts.owner)
    if opts.ipv6: cfg.ipv6 = opts.ipv6
    return cfg
Пример #2
0
def makeconsoleconfig(type, opts, botname=None):
    """ make config file based on options. """
    if not botname: botname = opts.name or "default-%s" % str(type)
    botname = stripname(botname)
    cfg = Config('fleet' + os.sep + botname + os.sep + 'config')
    cfg.type = type
    cfg.botname = botname
    if opts.loglevel: cfg.loglevel = opts.loglevel
    else: cfg.loglevel = cfg.loglevel or "error"
    return cfg
Пример #3
0
def makexmppconfig(type, opts=None, botname=None):
    """ make config file based on options. """
    if not opts: botname = botname or "default-sxmpp"
    else:
        if not botname: botname = opts.name or "default-sxmpp"
    botname = stripname(botname)
    cfg = Config('fleet' + os.sep + botname + os.sep + 'config')
    cfg.type = "sxmpp"
    cfg.botname = botname
    if not opts:
        cfg.user = ""
        cfg.host = ""
        cfg.password = ""
        cfg.server = ""
        cfg.jid = ""
        cfg.owner = []
        cfg.loglevel = "warn"
        return cfg
    if opts.user: cfg.user = opts.user
    else: cfg.user = cfg.user or "*****@*****.**" % cfg.uuid
    if opts.user:
        try:
            cfg.host = opts.user.split('@')[1]
        except ValueError:
            print "user is not in the nick@server format"
    if not cfg.host:
        try:
            cfg.host = cfg.user.split('@')[1]
        except ValueError:
            print "user is not in the nick@server format"
    if opts.password: cfg.password = opts.password
    if opts.server: cfg.server = opts.server
    else: cfg.server = cfg.server or "localhost"
    if opts.name: cfg.jid = opts.name
    if not cfg.owner: cfg.owner = []
    if opts.owner and opts.owner not in cfg.owner: cfg.owner.append(opts.owner)
    return cfg