-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
43 lines (38 loc) · 2.06 KB
/
config.py
File metadata and controls
43 lines (38 loc) · 2.06 KB
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
import configparser
class config:
def read(self):
self.config = configparser.ConfigParser()
self.config.read(self.configfile)
self.widelands = self.config._sections
self.widelands['server']['ssl'] = self.config.getboolean('server', 'ssl')
self.widelands['server']['sasl'] = self.config.getboolean('server', 'sasl')
self.widelands['server']['port'] = self.config.getint('server', 'port')
self.widelands['server']['retry'] = self.config.getint('server', 'retry')
self.widelands['nickserv']['replay'] = self.config.getboolean('nickserv', 'replay')
self.widelands['admin']['debug'] = self.config.getboolean('admin', 'debug')
self.widelands['ping']['interval'] = self.config.getint('ping', 'interval')
self.widelands['ping']['timeout'] = self.config.getint('ping', 'timeout')
self.widelands['ping']['pending'] = self.config.getboolean('ping', 'pending')
self.widelands['ping']['use'] = self.config.getboolean('ping', 'use')
self.widelands['webhook']['port'] = self.config.getint('webhook', 'port')
self.widelands['webhook']['start'] = self.config.getboolean('webhook', 'start')
self.channels = self.widelands['channel']['liste'].split(', ')
self.events = self.widelands['channel']['event'].split(', ')
self.trigger = "{}, ".format(self.widelands['nickserv']['username'])
def write(self):
with open(self.configfile, 'w') as configfile:
self.config.write(configfile)
def update(self, section, option, value):
if not section in self.config.sections():
self.config.add_section(section)
if isinstance(value, list):
value = ', '.join(value)
self.config.set(section, option, str(value))
self.widelands[section][option] = value
self.write()
def remove(self, section, option):
self.config.set(section, option, '')
self.widelands[section][option] = ''
self.write()
def ask(self, section, option):
return self.config.get(section, option)