|
@@ -235,3 +235,18 @@ async def imagine(args: Args, api_key: Config("text2img.api_key"), req: Request,
|
|
|
except:
|
|
|
logger.exception("Failed to call text2img service")
|
|
|
RollbotFailure.SERVICE_DOWN.raise_exc(detail="Failed to call text2img service")
|
|
|
+
|
|
|
+
|
|
|
+@as_command
|
|
|
+async def minecraft(minecraft_url: Config("minecraft.url"), req: Request):
|
|
|
+ try:
|
|
|
+ async with req.get(minecraft_url) as res:
|
|
|
+ res.raise_forstatus()
|
|
|
+ js = await res.json()
|
|
|
+ if not js['online']:
|
|
|
+ return "Server is offline!"
|
|
|
+ data = js['data']
|
|
|
+ return f"I see {data['currentPlayers']} people playing {data['motd']}"
|
|
|
+ except:
|
|
|
+ logger.exception("Failed to call MC service")
|
|
|
+ RollbotFailure.SERVICE_DOWN.raise_exc(detail="Failed to query Minecraft server")
|