Added auto-create config

This commit is contained in:
Notoric 2024-06-01 23:24:55 +01:00
parent 71b2927dc1
commit 41cf58cc9a
1 changed files with 29 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import time
import os
import json
import pymongo
import requests
@ -16,6 +17,34 @@ print(" |_____/|_| \_|\_____|")
# Load config
print("Loading config...")
if os.path.exists('config.json') == False:
print("Config file not found, Creating...")
config = {
"mongo" : {
"host" : "localhost",
"port" : 27017,
"db" : "notoric-snc"
},
"groq" : {
"api_key" : ""
},
"weather" : {
"api_key" : "",
"city" : "london,uk"
},
"news" : {
"api_key" : "",
"country" : "gb",
"article_lifetime": 6,
"article_interval": 1
}
}
with open('config.json', 'w') as f:
json.dump(config, f)
print("Config file created! Please fill in the details in config.json before running the script again.")
exit()
with open('config.json') as f:
config = json.load(f)