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
|
||||
logs
|
||||
config.json
|
||||
extensions
|
||||
lina.log
|
||||
|
|
10
bot.py
10
bot.py
|
@ -38,8 +38,9 @@ class Lina(commands.Bot):
|
|||
"""
|
||||
|
||||
pool: asyncpg.Pool
|
||||
stkserver: STKServer
|
||||
|
||||
def __init__(self, stkserver):
|
||||
def __init__(self):
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
|
@ -53,7 +54,6 @@ class Lina(commands.Bot):
|
|||
command_prefix=constants.PREFIX)
|
||||
|
||||
self.accent_color = constants.ACCENT_COLOR
|
||||
self.stkserver: STKServer = stkserver
|
||||
self.stk_userid: int = None
|
||||
self.stk_token: str = None
|
||||
|
||||
|
@ -201,6 +201,9 @@ class Lina(commands.Bot):
|
|||
finally:
|
||||
await self.session.close()
|
||||
|
||||
try:
|
||||
await self.stkserver.stop()
|
||||
finally:
|
||||
await super().close()
|
||||
|
||||
async def start(self):
|
||||
|
@ -221,3 +224,6 @@ class Lina(commands.Bot):
|
|||
async def on_ready(self):
|
||||
log.info(f"Bot {self.user} ({self.user.id}) is ready!")
|
||||
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 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):
|
||||
await bot.add_cog(Core(bot))
|
||||
|
|
|
@ -106,11 +106,13 @@ async def runBot():
|
|||
logger=log,
|
||||
cwd=os.getcwd() + "/stkserver",
|
||||
autostart=False,
|
||||
extra_args="--disable-addon-karts --disable-addon-tracks",
|
||||
data_path="/usr/share/supertuxkart",
|
||||
extra_args=("--disable-addon-karts","--disable-addon-tracks"),
|
||||
datapath="/usr/share/supertuxkart",
|
||||
executable_path="/usr/bin/supertuxkart",
|
||||
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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue