More config...

This commit is contained in:
Lasse Studion 2022-12-18 09:01:45 +01:00
parent 71482713d5
commit 36a112a1dd
2 changed files with 8 additions and 3 deletions

View File

@ -58,11 +58,15 @@ def update_config(key, value):
return config
def get_config():
def get_config(check_for=False):
# Returns a config file, creating one if not existing.
if os.path.exists("config.json"):
with open("config.json") as f:
config = json.load(f)
if check_for:
for i in check_for:
if i not in config:
config = create_config()
else:
config = create_config()
return config

View File

@ -32,7 +32,7 @@ def start_bot(default=True):
if __name__ == "__main__":
conf = config.get_config()
conf = config.get_config(check_for=['dropbox_refresh_token', 'twitter_access_token_secret'])
if len(sys.argv) > 1:
if sys.argv[1].lower() == 'start':
@ -53,7 +53,8 @@ if __name__ == "__main__":
else:
first_tweet_id = start_bot(default=False)
else:
print('Exiting...')
print('\nExiting...\n')
exit()
conf = config.get_config()