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
def makeircconfig(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) from jsb.lib.config import Config cfg = Config('fleet' + os.sep + botname + os.sep + 'config') cfg.type = 'irc' cfg.name = botname if not opts: cfg.password = cfg.password or "" cfg.ssl = cfg.ssl or False cfg.port = cfg.port or 6667 cfg.server = cfg.server or "localhost" cfg.owner = cfg.owner or [] cfg.ipv6 = cfg.ipv6 or False cfg.nick = cfg.nick or "jsb" cfg.channels = [] return cfg if not cfg.channels: cfg.channels = [] if opts.enable: cfg.disable = 0 logging.warn("enabling %s bot in %s" % (botname, cfg.cfile)) if opts.password: cfg.password = opts.password if opts.ipv6: cfg.ipv6 = True else: cfg.ipv6 = cfg.ipv6 or False if opts.ssl: cfg.ssl = True else: cfg.ssl = cfg.ssl or False if opts.nossl: cfg.ssl = False if opts.port: cfg.port = opts.port or cfg.port or 6667 else: cfg.port = cfg.port or 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 if opts.nick: cfg.nick = opts.nick else: cfg.nick = cfg.nick or "jsb" if opts.username: cfg.username = opts.username else: cfg.username = cfg.username or "jsonbot" if opts.channel: if not opts.channel in cfg.channels: cfg.channels.append(opts.channel) else: cfg.channels = cfg.channels or [] return cfg
def makeircconfig(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) from jsb.lib.config import Config cfg = Config('fleet' + os.sep + botname + os.sep + 'config') cfg.type = 'irc' cfg.name = botname if not opts: cfg.password = cfg.password or "" cfg.ssl = cfg.ssl or False cfg.port = cfg.port or 6667 cfg.server = cfg.server or "localhost" cfg.owner = cfg.owner or [] cfg.ipv6 = cfg.ipv6 or False cfg.nick = cfg.nick or "jsb" cfg.channels = [] return cfg if not cfg.channels: cfg.channels = [] if not cfg.disable: cfg.disable = False if opts.password: cfg.password = opts.password if opts.ipv6: cfg.ipv6 = True else: cfg.ipv6 = cfg.ipv6 or False if opts.ssl: cfg.ssl = True else: cfg.ssl = cfg.ssl or False if opts.nossl: cfg.ssl = False if opts.port: cfg.port = opts.port or cfg.port or 6667 else: cfg.port = cfg.port or 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 if opts.nick: cfg.nick = opts.nick else: cfg.nick = cfg.nick or "jsb" if opts.username: cfg.username = opts.username else: cfg.username = cfg.username or "jsonbot" if opts.channel: if not opts.channel in cfg.channels: cfg.channels.append(opts.channel) else: cfg.channels = cfg.channels or [] return cfg