Simplify assigning default config values
parent
f39902f30c
commit
2153d27b1b
39
phenny
39
phenny
|
@ -155,32 +155,21 @@ def main(argv=None):
|
|||
module = imp.load_source(name, config_name)
|
||||
module.filename = config_name
|
||||
|
||||
if not hasattr(module, 'prefix'):
|
||||
module.prefix = r'\.'
|
||||
defaults = {
|
||||
'prefix': r'\.',
|
||||
'name': 'Phenny Palmersbot, http://inamidst.com/phenny/',
|
||||
'port': 6667,
|
||||
'ssl': False,
|
||||
'ca_certs': None,
|
||||
'ssl_cert': None,
|
||||
'ssl_key': None,
|
||||
'ipv6': False,
|
||||
'password': None,
|
||||
}
|
||||
|
||||
if not hasattr(module, 'name'):
|
||||
module.name = 'Phenny Palmersbot, http://inamidst.com/phenny/'
|
||||
|
||||
if not hasattr(module, 'port'):
|
||||
module.port = 6667
|
||||
|
||||
if not hasattr(module, 'ssl'):
|
||||
module.ssl = False
|
||||
|
||||
if not hasattr(module, 'ca_certs'):
|
||||
module.ca_certs = None
|
||||
|
||||
if not hasattr(module, 'ssl_cert'):
|
||||
module.ssl_cert = None
|
||||
|
||||
if not hasattr(module, 'ssl_key'):
|
||||
module.ssl_key = None
|
||||
|
||||
if not hasattr(module, 'ipv6'):
|
||||
module.ipv6 = False
|
||||
|
||||
if not hasattr(module, 'password'):
|
||||
module.password = None
|
||||
for key, value in defaults.items():
|
||||
if not hasattr(module, key):
|
||||
setattr(module, key, value)
|
||||
|
||||
if module.host == 'irc.example.net':
|
||||
error = ('Error: you must edit the config file first!\n' +
|
||||
|
|
Loading…
Reference in New Issue