2016-07-09 13:27:19 +12:00
|
|
|
import yaml
|
|
|
|
import pymysql.cursors
|
|
|
|
import asyncio
|
2016-07-17 08:26:30 +12:00
|
|
|
import json
|
2016-07-09 13:27:19 +12:00
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
|
|
|
with open("/home/phxntx5/public_html/Bonfire/config.yml", "r") as f:
|
|
|
|
global_config = yaml.load(f)
|
|
|
|
|
2016-07-11 09:57:52 +12:00
|
|
|
connection = None
|
|
|
|
|
2016-07-09 13:27:19 +12:00
|
|
|
db_default = global_config.get("db_default")
|
|
|
|
db_boops = global_config.get("db_boops")
|
2016-07-16 04:13:30 +12:00
|
|
|
db_perms = global_config.get("db_perms")
|
2016-07-09 13:27:19 +12:00
|
|
|
|
|
|
|
botDescription = global_config.get("description")
|
|
|
|
commandPrefix = global_config.get("command_prefix")
|
|
|
|
|
|
|
|
battleWins = global_config.get("battleWins", [])
|
|
|
|
defaultStatus = global_config.get("default_status", "")
|
|
|
|
botToken = global_config.get("bot_token", "")
|
|
|
|
ownerID = global_config.get("owner_id", "")
|
|
|
|
|
|
|
|
modCommands = global_config.get("modCommands", {})
|
|
|
|
adminCommands = global_config.get("adminCommands", {})
|
|
|
|
openCommands = global_config.get("openCommands", {})
|
|
|
|
ownerCommands = global_config.get("ownerCommands", {})
|
|
|
|
voiceCommands = global_config.get("voiceCommands", {})
|
2016-07-10 00:57:25 +12:00
|
|
|
|
2016-07-11 09:57:52 +12:00
|
|
|
|
2016-07-10 04:02:33 +12:00
|
|
|
def getCursor():
|
2016-07-10 04:33:48 +12:00
|
|
|
global connection
|
2016-07-10 00:57:25 +12:00
|
|
|
connection = pymysql.connect(host=global_config.get("db_host"), user=global_config.get("db_user"),
|
2016-07-11 09:57:52 +12:00
|
|
|
password=global_config.get("db_user_pass"), charset='utf8mb4',
|
|
|
|
cursorclass=pymysql.cursors.DictCursor)
|
2016-07-10 04:02:33 +12:00
|
|
|
return connection.cursor()
|
2016-07-10 04:33:48 +12:00
|
|
|
|
2016-07-11 09:57:52 +12:00
|
|
|
|
2016-07-10 04:33:48 +12:00
|
|
|
def closeConnection():
|
|
|
|
connection.commit()
|
|
|
|
connection.close()
|
2016-07-17 08:26:30 +12:00
|
|
|
|
|
|
|
def saveContent(key: str, content):
|
2016-07-18 04:34:49 +12:00
|
|
|
with open("/home/phxntx5/public_html/Bonfire/config.json", "r+") as jf:
|
2016-07-17 23:49:05 +12:00
|
|
|
data = json.load(jf)
|
|
|
|
jf.seek(0)
|
2016-07-18 05:11:47 +12:00
|
|
|
newData = dict(data)
|
|
|
|
newData[key] = content
|
|
|
|
jf.truncate()
|
|
|
|
try:
|
|
|
|
json.dump(newData, jf, indent=4)
|
|
|
|
except:
|
|
|
|
json.dump(data, jf, indent=4)
|
2016-07-18 05:12:57 +12:00
|
|
|
|
2016-07-18 05:11:47 +12:00
|
|
|
|
2016-07-17 23:49:05 +12:00
|
|
|
def getContent(key: str):
|
2016-07-18 03:17:47 +12:00
|
|
|
try:
|
2016-07-18 04:34:49 +12:00
|
|
|
with open("/home/phxntx5/public_html/Bonfire/config.json", "r+") as jf:
|
2016-07-18 03:17:47 +12:00
|
|
|
data = json.load(jf)
|
|
|
|
return data[key]
|
|
|
|
except KeyError:
|
|
|
|
return None
|