From 47e4912c9751231f40c2984a6e0c10ec44c43399 Mon Sep 17 00:00:00 2001 From: SharwOrange Date: Wed, 27 Dec 2023 22:06:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=94=AF=E6=8C=81=E4=BA=86?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=BA=BA=E6=95=B0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- connect.py | 24 ++++++++++++++++++++---- readme.md | 48 ------------------------------------------------ 2 files changed, 20 insertions(+), 52 deletions(-) delete mode 100644 readme.md diff --git a/connect.py b/connect.py index 5afb8de..b9a660a 100644 --- a/connect.py +++ b/connect.py @@ -192,12 +192,28 @@ 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") + elif content == '!!status': + server = JavaServer.lookup("192.168.1.6:25565") status=server.status() - message = Message(content=f"此服务器有 {status.players.online} 个玩家在线", - room_id=data['roomId']) + # query = server.query() + + # if status.players.online != 0: + # message = Message(content=f"此服务器有 {status.players.online} 个玩家在线\n当前在线玩家有 {.join(query.players.names)}",room_id=data['roomId']) + # else: + # message = Message(content=f"此服务器空无一人",room_id=data['roomId']) + + message = Message(content=f"此服务器有 {status.players.online} 个玩家在线",room_id=data['roomId']) + await sio.emit('sendMessage', message.to_json()) + + elif content == '!!players': + server = JavaServer.lookup("192.168.1.6:25565") + query = server.query() + players = query.players.names + message = Message(content=f"此服务器当前在线玩家有 {players}",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/readme.md b/readme.md deleted file mode 100644 index bb80d45..0000000 --- a/readme.md +++ /dev/null @@ -1,48 +0,0 @@ -# icalingua bot - -## 源项目 -本项目fork自[icalingua-python-bot](http://shenjack.top:5100/shenjack/icalingua-python-bot) \ -fork时版本[daf53ba226c844fb5eaf64fdf7d951720050590c](http://shenjack.top:5100/shenjack/icalingua-python-bot/commit/daf53ba226c844fb5eaf64fdf7d951720050590c) - -## 简介 - -这是一个基于 icalingua docker 版的 bot - -> 出于某个企鹅, 和保护 作者 和 原项目 ( ica ) 的原因 \ -> 功能请自行理解 - -## 使用方法 - -- 安装依赖 - -```powershell -python -m pip install -r requirement.txt -``` - -> 如果你想使用虚拟环境 \ -> 可以使用 `python -m venv venv` 创建虚拟环境 \ -> 然后使用 `venv\Scripts\activate` 激活虚拟环境 \ -> 最后使用 `python -m pip install -r requirement.txt` 安装依赖 - -- 修改配置文件 - -```powershell -Copy-Item config-temp.toml config.toml -# 欸我就用 powershell -``` - -- icalingua 启动! - -```bash -# 用你自己的方法启动你的 icalingua 后端 -# 例如 -docker start icalingua -# 或者 -docker up -d -``` - -- bot 启动! - -```powershell -python connect.py -``` \ No newline at end of file