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
11 changes: 10 additions & 1 deletion api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@ def get_secret():

def get_public_key():
"""Returns the bot's public key in `runtimeconfig.json`, if it exists."""
if config["public_key"]: return config["public_key"]
if config["public_key"] != "": return config["public_key"]
else: return "Public key has not been set."

def get_mode() -> bool:
"""Returns a boolean of the current runtime mode.\n\nReturns `True` if replit mode is active, returns `False` if replit mode is inactive."""
return config["replit"]

def ext_token(token_name: str) -> str:
"""Returns an external extra authorization token from `runtimeconfig.json`, if it exists."""
return str(config["other_keys"][token_name])
#except KeyError: return "This external authorization key does not exist."

def get_runtime_options() -> dict:
"""Returns a dict of all the client's runtime configuration options, as well as their respective values."""
return dict(config["runtime_options"])
19 changes: 17 additions & 2 deletions api/runtimeconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
"token": "",
"secret": "",
"public_key": "",
"runtime_options": [],
"replit": true
"runtime_options": {
"themes": false,
"log_messages": true,
"guild_log_blacklist": {},
"only_log_whitelist": false,
"guild_log_whitelist": {},
"ping_server_override": false,
"debug_mode": false,
"show_ping_on_startup": true
},
"replit": false,
"other_keys": {
"openweathermap": "",
"reddit": "",
"ossapi": "",
"chatgpt": ""
}
}
5 changes: 3 additions & 2 deletions cogs/osu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Imports
import discord
import os
from api import auth
from ossapi import *
from discord import option, ApplicationContext
from discord.ext import commands
Expand All @@ -11,8 +12,8 @@
class Osu(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.api = OssapiV2(13110, os.environ['ossapi_CLIENT_SECRET'])
self.api = OssapiV2(13110, auth.ext_token("ossapi"))

@commands.slash_command(
name="osu_user",
description="View information on an osu! player."
Expand Down
5 changes: 3 additions & 2 deletions cogs/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
import discord
import praw
import os
from api import auth
from discord import ApplicationContext, option
from discord.ext import commands
from random import randint

# Variables
color = discord.Color.random()
reddit = praw.Reddit(client_id='_pazwWZHi9JldA', client_secret=os.environ['reddit_CLIENT_SECRET'], user_agent='idk', check_for_async=False)
reddit = praw.Reddit(client_id='_pazwWZHi9JldA', client_secret=auth.ext_token('reddit'), user_agent='idk', check_for_async=False)

# Commands
class RedditMedia(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.slash_command(
name='memes',
description='Finely hand-picks a high-quality meme from the depths of reddit.'
Expand Down
4 changes: 3 additions & 1 deletion cogs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import psutil
import openai
import discord
from api import auth
from framework.isobot import currency, embedengine, commands as cmds
from framework.isobot.db import levelling
from discord import option, ApplicationContext
Expand All @@ -17,7 +18,8 @@
color = discord.Color.random()
currency = currency.CurrencyAPI("database/currency.json", "logs/currency.log")
levelling = levelling.Levelling()
openai.api_key = os.getenv("chatgpt_API_KEY")
# openai.api_key = os.getenv("chatgpt_API_KEY")
openai.api_key = auth.ext_token('chatgpt')
chatgpt_conversation = dict()
_presence = Presence()

Expand Down
4 changes: 3 additions & 1 deletion cogs/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import json
import requests
import os
from api import auth
from framework.isobot.db import weather
from discord import ApplicationContext, option
from discord.ext import commands

# Variables
api_key = os.environ['openweathermap_API_KEY']
#api_key = os.environ['openweathermap_API_KEY']
api_key = auth.ext_token('openweathermap')
weather = weather.Weather()

# Commands
Expand Down