Added new method for saving content as a json file instead of mysql
This commit is contained in:
parent
c849dd2bf6
commit
9a880d343c
|
@ -83,10 +83,11 @@ class Core:
|
||||||
url += query
|
url += query
|
||||||
|
|
||||||
# This will check if the channel is a 'nsfw' channel, if so add 'explicit' to the search term
|
# This will check if the channel is a 'nsfw' channel, if so add 'explicit' to the search term
|
||||||
cursor = config.getCursor()
|
#cursor = config.getCursor()
|
||||||
cursor.execute('use {}'.format(config.db_default))
|
#cursor.execute('use {}'.format(config.db_default))
|
||||||
cursor.execute('select * from nsfw_channels')
|
#cursor.execute('select * from nsfw_channels')
|
||||||
result = cursor.fetchall()
|
#result = cursor.fetchall()
|
||||||
|
nsfw_channels = config.getContent("nsfw_channels")
|
||||||
if {'channel_id': '{}'.format(ctx.message.channel.id)} in result:
|
if {'channel_id': '{}'.format(ctx.message.channel.id)} in result:
|
||||||
url += ",+explicit&filter_id=95938"
|
url += ",+explicit&filter_id=95938"
|
||||||
config.closeConnection()
|
config.closeConnection()
|
||||||
|
|
|
@ -42,7 +42,15 @@ def closeConnection():
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
def saveContent(key: str, content):
|
def saveContent(key: str, content):
|
||||||
with open("/home/phxntx5/public_html/Bonfire/config.json", "r+") as f:
|
with open("/home/phxntx5/public_html/Bonfire/config.json", "r+") as jf:
|
||||||
jfile = json.load(f)
|
data = json.load(jf)
|
||||||
if key in content:
|
data[key] = content
|
||||||
jfile[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]
|
||||||
|
|
Loading…
Reference in a new issue