integrate stk server starting
This commit is contained in:
parent
1963ec5946
commit
df37890dcf
4 changed files with 28 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@ venv
|
||||||
stkserver
|
stkserver
|
||||||
logs
|
logs
|
||||||
config.json
|
config.json
|
||||||
|
extensions
|
||||||
|
lina.log
|
||||||
|
|
12
bot.py
12
bot.py
|
@ -38,8 +38,9 @@ class Lina(commands.Bot):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pool: asyncpg.Pool
|
pool: asyncpg.Pool
|
||||||
|
stkserver: STKServer
|
||||||
|
|
||||||
def __init__(self, stkserver):
|
def __init__(self):
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
|
@ -53,7 +54,6 @@ class Lina(commands.Bot):
|
||||||
command_prefix=constants.PREFIX)
|
command_prefix=constants.PREFIX)
|
||||||
|
|
||||||
self.accent_color = constants.ACCENT_COLOR
|
self.accent_color = constants.ACCENT_COLOR
|
||||||
self.stkserver: STKServer = stkserver
|
|
||||||
self.stk_userid: int = None
|
self.stk_userid: int = None
|
||||||
self.stk_token: str = None
|
self.stk_token: str = None
|
||||||
|
|
||||||
|
@ -201,7 +201,10 @@ class Lina(commands.Bot):
|
||||||
finally:
|
finally:
|
||||||
await self.session.close()
|
await self.session.close()
|
||||||
|
|
||||||
await super().close()
|
try:
|
||||||
|
await self.stkserver.stop()
|
||||||
|
finally:
|
||||||
|
await super().close()
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
"""Bring lina to life"""
|
"""Bring lina to life"""
|
||||||
|
@ -221,3 +224,6 @@ class Lina(commands.Bot):
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
log.info(f"Bot {self.user} ({self.user.id}) is ready!")
|
log.info(f"Bot {self.user} ({self.user.id}) is ready!")
|
||||||
self.stkPoll.start()
|
self.stkPoll.start()
|
||||||
|
log.info("Starting verification server.")
|
||||||
|
await self.stkserver.launch()
|
||||||
|
|
||||||
|
|
12
cogs/core.py
12
cogs/core.py
|
@ -77,5 +77,17 @@ class Core(commands.Cog):
|
||||||
await ctx.reply("Shutting down :wave:")
|
await ctx.reply("Shutting down :wave:")
|
||||||
await self.bot.close()
|
await self.bot.close()
|
||||||
|
|
||||||
|
@commands.command(hidden=True)
|
||||||
|
async def shutdownverificationserver(self, ctx: commands.Context):
|
||||||
|
self.bot.stkserver.restart = False
|
||||||
|
await ctx.reply("Shutting down verification server.")
|
||||||
|
await self.bot.stkserver.stop()
|
||||||
|
|
||||||
|
@commands.command(hidden=True)
|
||||||
|
async def restartverificationserver(self, ctx: commands.Context):
|
||||||
|
self.bot.stkserver.restart = True
|
||||||
|
await ctx.reply("Restarting verification server.")
|
||||||
|
await self.bot.stkserver.stop()
|
||||||
|
|
||||||
async def setup(bot: Lina):
|
async def setup(bot: Lina):
|
||||||
await bot.add_cog(Core(bot))
|
await bot.add_cog(Core(bot))
|
||||||
|
|
|
@ -106,11 +106,13 @@ async def runBot():
|
||||||
logger=log,
|
logger=log,
|
||||||
cwd=os.getcwd() + "/stkserver",
|
cwd=os.getcwd() + "/stkserver",
|
||||||
autostart=False,
|
autostart=False,
|
||||||
extra_args="--disable-addon-karts --disable-addon-tracks",
|
extra_args=("--disable-addon-karts","--disable-addon-tracks"),
|
||||||
data_path="/usr/share/supertuxkart",
|
datapath="/usr/share/supertuxkart",
|
||||||
executable_path="/usr/bin/supertuxkart",
|
executable_path="/usr/bin/supertuxkart",
|
||||||
name="linaSTK Verification Server",
|
name="linaSTK Verification Server",
|
||||||
cfgpath=os.getcwd() + "/stkserver/config.xml"
|
cfgpath=os.getcwd() + "/stkserver/config.xml",
|
||||||
|
writeln=lambda _: None,
|
||||||
|
extra_env={"XDG_DATA_DIRS": ""}
|
||||||
)
|
)
|
||||||
await lina.start()
|
await lina.start()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue