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
|
||||
|
||||
# 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()
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue