From 4d38da674eeb83ab5acea23910ded9f8a9e9d380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SharwOrange=E6=A9=99=E5=A4=9C?= Date: Tue, 26 Dec 2023 10:42:25 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SharwOrange橙夜 --- connect.py | 8 +++++++- requirement.txt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/connect.py b/connect.py index 0733340..5afb8de 100644 --- a/connect.py +++ b/connect.py @@ -10,7 +10,7 @@ import socketio from colorama import Fore, Style from nacl.signing import SigningKey from lib_not_dr.types import Options - +from mcstatus import JavaServer def get_config() -> Tuple[str, str, int]: with open('config.toml', 'r', encoding='utf-8') as f: @@ -192,6 +192,12 @@ async def add_message(data: Dict[str, Any]): message = Message(content='icalingua bot test', room_id=data['roomId']) await sio.emit('sendMessage', message.to_json()) + if content == '!!status': + server = JavaServer.lookup("server1.xfcloud.org") + status=server.status() + message = Message(content=f"此服务器有 {status.players.online} 个玩家在线", + room_id=data['roomId']) + await sio.emit('sendMessage', message.to_json()) elif data.get('message').get('content').startswith('=='): evals: str = data.get('message').get('content')[2:] diff --git a/requirement.txt b/requirement.txt index 4c7f521..4baec2e 100644 --- a/requirement.txt +++ b/requirement.txt @@ -3,3 +3,4 @@ colorama rtoml pynacl python-socketio[asyncio_client] +mcstatus \ No newline at end of file