-
Notifications
You must be signed in to change notification settings - Fork 101
/
configs.py
50 lines (37 loc) · 1.53 KB
/
configs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
"""
configs.py - jenni IRC bot config manager
Copyright 2009-2015, yano (yanovich.net)
Copyright 2008-2013, Sean B. Palmer (inamidst.com)
Licensed under the Eiffel Forum License 2.
Written by kaneda (http://jbegleiter.com), is invoked in
the jenni starter to store the config helper in jenni.config
More info:
* jenni: https://github.com/myano/jenni/
* Phenny: http://inamidst.com/phenny/
"""
import imp, os, sys
class Configs():
def __init__(self, config_paths):
self.config_paths = config_paths
def load_modules(self, config_modules):
for config_name in self.config_paths:
name = os.path.basename(config_name).split('.')[0] + '_config'
module = imp.load_source(name, config_name)
module.filename = config_name
if not hasattr(module, 'prefix'):
module.prefix = r'\.'
if not hasattr(module, 'name'):
module.name = 'jenni yanosbot, https://git.io/jenni'
if not hasattr(module, 'port'):
module.port = 6667
if not hasattr(module, 'password'):
module.password = None
if not hasattr(module, 'ssl'):
module.ssl = False
if module.host == 'irc.example.net':
error = ('Error: you must edit the config file first!\n' +
"You're currently using %s" % module.filename)
print >> sys.stderr, error
sys.exit(1)
config_modules.append(module)