Skip to content

Commit abfbff7

Browse files
author
ProfMobius
committed
DB connection is now in the config file
1 parent 259d02f commit abfbff7

File tree

4 files changed

+41
-27
lines changed

4 files changed

+41
-27
lines changed

Diff for: .idea/workspace.xml

+26-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: BotBase.py

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def getConfig(self, section, option, default):
8686
return self.config.get(section, option)
8787
else:
8888
self.config.set(section, option, default)
89+
self.updateConfig()
8990
return self.config.get(section, option)
9091

9192
# User handling commands

Diff for: MCPBot.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
class MCPBot(BotBase):
66
def __init__(self):
77
super(MCPBot, self).__init__()
8-
self.db = Database('172.245.30.34', 5432, 'postgres', 'mcpbot', 'MCPBot0', self)
8+
self.dbhost = self.getConfig('DATABASE', 'HOST', "")
9+
self.dbport = int(self.getConfig('DATABASE', 'PORT', "0"))
10+
self.dbuser = self.getConfig('DATABASE', 'USER', "")
11+
self.dbname = self.getConfig('DATABASE', 'NAME', "")
12+
self.dbpass = self.getConfig('DATABASE', 'PASS', "")
13+
14+
self.db = Database(self.dbhost, self.dbport, self.dbuser, self.dbname, self.dbpass, self)
915

1016
self.registerCommand('sqlrequest', self.sqlrequest, ['admin'], 1, 999, "Execute a raw SQL command")
1117

Diff for: bot.cfg

+7
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ timeout = 60
3737
active = true
3838
allowanon = false
3939

40+
[DATABASE]
41+
host = 172.245.30.34
42+
port = 5432
43+
user = postgres
44+
name = mcpbot
45+
pass = MCPBot0
46+

0 commit comments

Comments
 (0)