1
0
Fork 0
mirror of synced 2024-05-18 19:42:28 +12:00

Added new method for saving content as a json file instead of mysql

This commit is contained in:
Phxntxm 2016-07-17 06:49:05 -05:00
parent c849dd2bf6
commit 9a880d343c
2 changed files with 17 additions and 8 deletions

View file

@ -83,10 +83,11 @@ class Core:
url += query
# This will check if the channel is a 'nsfw' channel, if so add 'explicit' to the search term
cursor = config.getCursor()
cursor.execute('use {}'.format(config.db_default))
cursor.execute('select * from nsfw_channels')
result = cursor.fetchall()
#cursor = config.getCursor()
#cursor.execute('use {}'.format(config.db_default))
#cursor.execute('select * from nsfw_channels')
#result = cursor.fetchall()
nsfw_channels = config.getContent("nsfw_channels")
if {'channel_id': '{}'.format(ctx.message.channel.id)} in result:
url += ",+explicit&filter_id=95938"
config.closeConnection()

View file

@ -42,7 +42,15 @@ def closeConnection():
connection.close()
def saveContent(key: str, content):
with open("/home/phxntx5/public_html/Bonfire/config.json", "r+") as f:
jfile = json.load(f)
if key in content:
jfile[key]= content
with open("/home/phxntx5/public_html/Bonfire/config.json", "r+") as jf:
data = json.load(jf)
data[key] = content
jf.seek(0)
json.dump(data, jf, indent=4)
jf.close()
def getContent(key: str):
with open("/home/phxntx5/public_html/Bonfire/config.json", "r+") as jf:
data = json.load(jf)
jf.close()
return data[key]