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