-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
208b9a0
commit c1dcd12
Showing
5 changed files
with
70 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[python] | ||
path = "C:/Users/blueg/AppData/Local/Programs/Python/Python39/python.EXE" | ||
path = "C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Python\\Python39\\python.EXE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import List, Optional | ||
from graia.ariadne.app import Ariadne | ||
from graia.ariadne.event.message import MessageEvent | ||
from graia.ariadne.message.chain import MessageChain | ||
from graia.ariadne.message.element import Image, Plain | ||
import mcstatus | ||
from graia.saya import Channel | ||
from mcstatus.pinger import PingResponse | ||
from graia.ariadne.message.commander.saya import CommandSchema | ||
|
||
channel = Channel.current() | ||
|
||
@channel.use( | ||
CommandSchema("[.server|服务器] {server_address:str}") | ||
) | ||
async def get_info(event: MessageEvent, app: Ariadne, server_address: str): | ||
try: | ||
server = mcstatus.MinecraftServer.lookup(server_address) | ||
stat = await server.async_status() | ||
players: Optional[List[PingResponse.Players.Player]] = stat.players.sample | ||
except Exception as e: | ||
reply = MessageChain.create( | ||
[ | ||
Plain(f"{repr(e)}"), | ||
] | ||
) | ||
else: | ||
reply = MessageChain( | ||
[ | ||
Plain(f"{server_address} 状态\n"), | ||
Image(base64=stat.favicon.removeprefix("data:image/png;base64,")) | ||
if stat.favicon is not None | ||
else Plain(""), | ||
Plain( | ||
f"玩家数:{stat.players.online}/{stat.players.max}\n" | ||
f"延迟:{stat.latency}ms\n" | ||
"在线玩家:\n" | ||
), | ||
Plain( | ||
"\n".join(i.name for i in players) if players is not None else "无" | ||
), | ||
] | ||
) | ||
del server, stat | ||
await app.sendMessage(event, reply) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,29 @@ | ||
[project] | ||
name = "" | ||
version = {from = "lib/__init__.py"} | ||
version = { from = "lib/__init__.py" } | ||
description = "" | ||
authors = [ | ||
{name = "BlueGlassBlock", email = "[email protected]"}, | ||
] | ||
dependencies = [ | ||
"graia-ariadne[full]>=0.5.3.post3", | ||
"toml>=0.10.2", | ||
"peewee>=3.14.8", | ||
] | ||
authors = [{ name = "BlueGlassBlock", email = "[email protected]" }] | ||
dependencies = ["graia-ariadne[full]>=0.6.0", "toml>=0.10.2", "peewee>=3.14.8"] | ||
requires-python = ">=3.9" | ||
license = {text = "AGPL-3.0"} | ||
license = { text = "AGPL-3.0" } | ||
|
||
[project.urls] | ||
homepage = "" | ||
|
||
[project.optional-dependencies] | ||
plugin = [ | ||
"pillow>=9.0.1", | ||
"mcstatus>=6.5.0", | ||
] | ||
plugin = ["pillow>=9.0.1", "mcstatus>=6.5.0"] | ||
|
||
[tool] | ||
|
||
[tool.pdm] | ||
|
||
[tool.pdm.dev-dependencies] | ||
dev = [ | ||
"black>=22.1.0", | ||
"isort>=5.10.1", | ||
"flake8>=4.0.1", | ||
] | ||
|
||
[tool.pdm.scripts] | ||
xenon = "python main.py" | ||
|
||
|
@@ -40,4 +35,4 @@ build-backend = "pdm.pep517.api" | |
profile = "black" | ||
|
||
[tool.black] | ||
line-length = "110" | ||
line-length = "110" |