- 高危词库从 process.py 抽到 config.toml [security] section - process.py 改为 _get_high_risk_words() 动态加载(配置优先) - 新增 15 个 QQ 操作脚本(已脱敏:QQ号/IP/Token → 占位符) - 新增 8 个 SKILL.md(qq-messenger/management/resolver/napcat-extras 等) - 新增 SKILL.md 入口(完整部署方案文档) - 保留 SDK 框架(plugin_modules.py, file_store_api.py, package.py 等)
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
||
"""清理Minecraft地面掉落物(含倒计时,通过RCON通知玩家)"""
|
||
|
||
import sys, os, re, time
|
||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||
from mc_config import RCON_HOST, RCON_PORT, RCON_PASSWORD
|
||
from mc_rcon import RCONClient
|
||
|
||
def clear_items():
|
||
killed = 0
|
||
error = None
|
||
client = RCONClient(RCON_HOST, RCON_PORT, RCON_PASSWORD)
|
||
try:
|
||
client.connect()
|
||
# 验证连接
|
||
resp = client.send_command("list")
|
||
if resp is None:
|
||
raise Exception("无法连接到Minecraft RCON服务")
|
||
|
||
# 30秒倒计时
|
||
for i in range(30, 0, -1):
|
||
if i in (30, 20, 10, 5, 4, 3, 2, 1):
|
||
client.send_command(f'tellraw @a ["\\u00a7e\\u26a0\\ufe0f 将在 {i} 秒后清理地面掉落物,请捡起你的物品!"]')
|
||
time.sleep(1)
|
||
|
||
client.send_command('tellraw @a ["\\u00a7c\\ud83e\\uddf9 正在清理地面掉落物..."]')
|
||
time.sleep(0.5)
|
||
kill_resp = client.send_command("kill @e[type=item]")
|
||
|
||
body = kill_resp.get("body", "") if kill_resp else ""
|
||
m = re.search(r'Killed (\d+) entities', body)
|
||
killed = int(m.group(1)) if m else 0
|
||
|
||
client.send_command(f'tellraw @a ["\\u00a7a\\u2705 已清理 {killed} 个掉落物"]')
|
||
except Exception as e:
|
||
error = str(e)
|
||
try:
|
||
client.send_command('tellraw @a ["\\u00a7c清理掉落物时发生错误"]')
|
||
except Exception:
|
||
pass
|
||
finally:
|
||
client.close()
|
||
|
||
import json
|
||
result = {"killed": killed, "error": error}
|
||
print(json.dumps(result, ensure_ascii=False))
|
||
return result
|
||
|
||
if __name__ == "__main__":
|
||
clear_items()
|