Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
api/runtimeconfig.json
*.log
*.pyc
__pycache__
Expand Down
20 changes: 8 additions & 12 deletions api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,26 @@
from typing_extensions import Literal

# Config
wdir = os.getcwd()
wdir = f"{os.path.expanduser('~')}/.isobot"

# Setup
def load_config() -> dict:
"""Loads the runtimeconfig file and returns the contents as a `dict`."""
with open(f'{wdir}/api/runtimeconfig.json', 'r') as f:
with open(f'{wdir}/runtimeconfig.json', 'r') as f:
return json.load(f)

def initial_setup() -> Literal[0]:
# Building runtimeconfig files and directory IF missing:
"""Checks whether the required runtimeconfig files are present in the bot runtime directory.\n\nReturns `0` if successful."""
if not os.path.isdir("api"):
print(f"[!] Runtimeconfig directory not found. Building runtime configuration files...")
print(" > [1/3] Creating client api directory...")
os.mkdir("api")
if not os.path.isfile("api/runtimeconfig.json"):
if not os.path.isfile(f"{wdir}/runtimeconfig.json"):
print(f"[!] Runtimeconfig not found. Building runtime configuration files...")
print(" > Creating runtimeconfig file...")
with open('api/runtimeconfig.json', 'x') as f: # Create a new file for runtimeconfig
with open(f'{wdir}/runtimeconfig.json', 'x') as f: # Create a new file for runtimeconfig
json.dump({}, f)
f.close()

# Check whether any keys are missing in runtimeconfig file, and add them accordingly:
with open('api/runtimeconfig.json', 'r') as f: runtimeconfig_db = json.load(f)
with open(f'{wdir}/runtimeconfig.json', 'r') as f: runtimeconfig_db = json.load(f)
required_keys = ("token", "alt_token_path", "secret", "public_key", "runtime_options", "replit", "other_keys")
for key in required_keys:
if key not in runtimeconfig_db:
Expand All @@ -39,7 +35,7 @@ def initial_setup() -> Literal[0]:
runtimeconfig_db[key] = False
else:
runtimeconfig_db[key] = ""
with open('api/runtimeconfig.json', 'w+') as f: json.dump(runtimeconfig_db, f, indent=4)
with open(f'{wdir}/runtimeconfig.json', 'w+') as f: json.dump(runtimeconfig_db, f, indent=4)

default_runtime_option_values = {
"themes": False,
Expand All @@ -63,7 +59,7 @@ def initial_setup() -> Literal[0]:
print(f"[!] Update available for runtimeconfig. Updating configuration...")
runtimeconfig_db["other_keys"][key] = ""

with open('api/runtimeconfig.json', 'w+') as f: json.dump(runtimeconfig_db, f, indent=4)
with open(f'{wdir}/runtimeconfig.json', 'w+') as f: json.dump(runtimeconfig_db, f, indent=4)
return 0

# Commands
Expand All @@ -84,7 +80,7 @@ def get_token():
if arg1.lower() == "y" or arg1.lower() == "yes":
arg2 = input("Enter your custom token: ")
config["token"] = str(arg2)
with open(f'{wdir}/api/runtimeconfig.json', 'w+') as f: json.dump(config, f, indent=4)
with open(f'{wdir}/runtimeconfig.json', 'w+') as f: json.dump(config, f, indent=4)
print("[✅] Setup successful!")
elif arg1.lower() == "n" or arg1.lower() == "no": return
return str(config["token"])
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import datetime
import discord, discord.errors
import asyncio
import api.auth
import config_updater

# Run Config Updater
Expand Down Expand Up @@ -126,6 +125,9 @@ def initial_setup():

initial_setup() # Check for any missing sub-directories or databases in bot directory

# Import Client API Library
import api.auth

# Framework Module Loader
colors = colors.Colors()
s = logger.StartupLog(f"{client_data_dir}/logs/startup-log.txt", clear_old_logs=True)
Expand Down