mirror of
https://github.com/RGBCube/minearchy-bot
synced 2025-07-27 00:47:44 +00:00
Add psutil
This commit is contained in:
parent
e3b5e21eee
commit
75caf959a3
2 changed files with 27 additions and 1 deletions
|
@ -3,7 +3,9 @@ from __future__ import annotations
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext import commands, tasks
|
||||
import subprocess
|
||||
import psutil
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bot import MinearchyBot
|
||||
|
@ -17,6 +19,12 @@ class MinecraftServer(
|
|||
def __init__(self, bot: MinearchyBot) -> None:
|
||||
self.bot = bot
|
||||
|
||||
async def cog_load(self) -> None:
|
||||
self.check_processes_up.start()
|
||||
|
||||
async def cog_unload(self) -> None:
|
||||
self.check_processes_up.cancel()
|
||||
|
||||
@commands.group(
|
||||
invoke_without_command=True,
|
||||
brief="Sends the server IP.",
|
||||
|
@ -89,6 +97,23 @@ class MinecraftServer(
|
|||
)
|
||||
await ctx.reply(view=view)
|
||||
|
||||
@tasks.loop(minutes=5)
|
||||
async def check_processes_up(self) -> None:
|
||||
pass
|
||||
# pids = [
|
||||
# int(pid)
|
||||
# for pid in subprocess.Popen(
|
||||
# ["ps", "aux", "|", "grep", "java"], stdout=subprocess.PIPE
|
||||
# )
|
||||
# .communicate()[0]
|
||||
# .splitlines()
|
||||
# ]
|
||||
# await self.bot.log_webhook.send(f"```\n{pids!r}```")
|
||||
#
|
||||
# for pid in pids:
|
||||
# if not psutil.pid_exists(pid):
|
||||
# await self.bot.log_webhook.send(f"No such pid: {pid}")
|
||||
|
||||
|
||||
async def setup(bot: MinearchyBot) -> None:
|
||||
await bot.add_cog(MinecraftServer(bot))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
discord.py @ git+https://github.com/Rapptz/discord.py
|
||||
jishaku==2.5.0
|
||||
mcstatus
|
||||
psutil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue