remove hard-coded git-url & minor restructuring
This commit is contained in:
parent
d6519d5133
commit
9049b5e637
5 changed files with 12 additions and 6 deletions
0
ext/__init__.py
Normal file
0
ext/__init__.py
Normal file
|
@ -4,6 +4,10 @@ import asyncio
|
|||
import lightbulb
|
||||
import hikari
|
||||
|
||||
from lib.config import load_config
|
||||
|
||||
config = load_config()
|
||||
|
||||
plugin = lightbulb.Plugin("SystemPlugin")
|
||||
|
||||
async def get_git_status() -> dict:
|
||||
|
@ -52,7 +56,7 @@ async def ping(ctx: lightbulb.Context) -> None:
|
|||
async def info(ctx: lightbulb.Context) -> None:
|
||||
git_status = await get_git_status()
|
||||
embed = hikari.Embed(title="About Me!")
|
||||
embed.add_field("GitHub", "https://gitdab.com/InValidFire/radical-bot")
|
||||
embed.add_field("GitHub", config.git_url)
|
||||
embed.add_field("Version", git_status['commit_id'], inline=True)
|
||||
embed.add_field("Branch", git_status['branch'], inline=True)
|
||||
embed.add_field("In Dev-Env?", git_status['dev'])
|
||||
|
|
0
lib/__init__.py
Normal file
0
lib/__init__.py
Normal file
|
@ -7,20 +7,22 @@ class Config(object):
|
|||
discord_token: str | None = None
|
||||
discord_guild_id: int | None = None
|
||||
git_branch: str | None = None
|
||||
git_url: str | None = None
|
||||
|
||||
def config_decoder(obj):
|
||||
if '__type__' in obj and obj['__type__'] == "Config":
|
||||
return Config(
|
||||
discord_token=obj['discord_token'],
|
||||
discord_guild_id=obj['discord_guild_id'],
|
||||
git_branch=obj['git_branch']
|
||||
git_branch=obj['git_branch'],
|
||||
git_url=obj['git_url']
|
||||
)
|
||||
|
||||
def save(config: dict):
|
||||
def save_config(config: dict):
|
||||
with Path("config.json").open("w+", encoding="utf-8") as fp:
|
||||
json.dump(config, fp, indent=4)
|
||||
|
||||
def load():
|
||||
def load_config():
|
||||
with Path("config.json").open("r", encoding="utf-8") as fp:
|
||||
config = json.load(fp, object_hook=config_decoder)
|
||||
return config
|
4
main.py
4
main.py
|
@ -1,8 +1,8 @@
|
|||
import lightbulb
|
||||
|
||||
from config import load
|
||||
from lib.config import load_config
|
||||
|
||||
config = load()
|
||||
config = load_config()
|
||||
|
||||
bot = lightbulb.BotApp(config.discord_token, default_enabled_guilds=[config.discord_guild_id])
|
||||
bot.load_extensions_from("ext/")
|
||||
|
|
Loading…
Reference in a new issue