forked from JustTrott/Python6Mans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
48 lines (38 loc) · 1.21 KB
/
Copy pathconfig.py
File metadata and controls
48 lines (38 loc) · 1.21 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
44
45
46
47
48
import os
import configparser as cp
configFile = "config.ini"
discordGroup = "Discord"
tokenKey = "token"
prefixKey = "prefix"
channelKey = "channel"
lbsizeKey = "sizekey"
class Config:
def __init__(self):
self.cp = cp.ConfigParser()
self.check_config()
def check_config(self):
if os.path.isfile(configFile):
self.cp.read(configFile)
return
print('No config.ini file. Creating a default one.')
self.create_config()
def create_config(self):
self.cp[discordGroup] = {}
self.cp[discordGroup][tokenKey] = ""
self.cp[discordGroup][prefixKey] = ""
self.cp[discordGroup][channelKey] = ""
self.cp[discordGroup][lbsizeKey] = ""
with open(configFile, "w") as file:
self.cp.write(file)
@property
def bot_token(self):
return self.cp[discordGroup][tokenKey]
@property
def command_prefix(self):
return self.cp[discordGroup][prefixKey]
@property
def queue_channel(self):
return self.cp[discordGroup][channelKey]
@property
def lobby_size(self):
return self.cp[discordGroup][lbsizeKey]