Update minimal modpack to version 0.0.12
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
"type": "forge",
|
||||
"version": "1.20.1"
|
||||
},
|
||||
"versionId": "0.0.11",
|
||||
"versionId": "0.0.12",
|
||||
"name": "minimal-client-modpack",
|
||||
"summary": "Minimal client modpack for connecting to the server"
|
||||
"files": [
|
||||
|
||||
1
state/excluded_mods.json
Normal file
1
state/excluded_mods.json
Normal file
@ -0,0 +1 @@
|
||||
["[GD656\u51fb\u6740\u56fe\u6807] gd656killicon-1.1.1.002-1.20.1-forge.jar", "[Xaero\u7684\u4e16\u754c\u5730\u56fe] xaeroworldmap-forge-1.20.1-1.40.11.jar", "[Xaero\u7684\u5c0f\u5730\u56fe] xaerominimap-forge-1.20.1-25.3.10.jar", "[\u4e00\u952e\u80cc\u5305\u6574\u7406Next] InventoryProfilesNext-forge-1.20-1.10.20.jar", "[\u4e07\u7528\u76ae\u80a4\u8865\u4e01] CustomSkinLoader_ForgeV2-14.26.1.jar", "[\u521b\u4e16\u795e] worldedit-mod-7.2.15.jar", "[\u5e15\u79cb\u8389\u624b\u518c] Patchouli-1.20.1-85-FORGE.jar", "[\u81ea\u7136\u97f3\u6548] AmbientSounds_FORGE_v6.3.4_mc1.20.1.jar", "[\u82f9\u679c\u76ae] appleskin-forge-mc1.20.1-2.5.1.jar", "[\u9884\u751f\u6210\u533a\u5757] Chunky-1.3.146.jar", "spark-1.10.53-forge.jar"]
|
||||
@ -3,6 +3,8 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import hashlib
|
||||
import json
|
||||
import urllib.request
|
||||
from datetime import datetime
|
||||
|
||||
REPO_DIR = "/tmp/mod_repo"
|
||||
@ -14,6 +16,8 @@ MODPACK_DIR = f"{REPO_DIR}/modpack"
|
||||
VERSION_FILE = f"{REPO_DIR}/VERSION"
|
||||
TRUEMODS_DIR = f"{REPO_DIR}/truemods"
|
||||
TRUEGUNPACKS_DIR = f"{REPO_DIR}/truegunpacks"
|
||||
QQ_GROUP_ID = "814734369" # Minecraft group
|
||||
QQ_API_URL = "http://192.168.2.106:25570"
|
||||
|
||||
CLIENT_ONLY_MODS = [
|
||||
"xaero", "ambient", "apple", "inventoryprofiles",
|
||||
@ -41,6 +45,17 @@ def get_hash(path):
|
||||
with open(path, 'rb') as f:
|
||||
return hashlib.sha1(f.read()).hexdigest()
|
||||
|
||||
def load_previous_state():
|
||||
prev_mods = []
|
||||
prev_excluded = []
|
||||
if os.path.exists(f"{STATE_DIR}/mods.json"):
|
||||
with open(f"{STATE_DIR}/mods.json", 'r') as f:
|
||||
prev_mods = [line.strip() for line in f if line.strip()]
|
||||
if os.path.exists(f"{STATE_DIR}/excluded_mods.json"):
|
||||
with open(f"{STATE_DIR}/excluded_mods.json", 'r') as f:
|
||||
prev_excluded = json.load(f)
|
||||
return prev_mods, prev_excluded
|
||||
|
||||
def sync_minimal_pack():
|
||||
for d in [TRUEMODS_DIR, TRUEGUNPACKS_DIR]:
|
||||
if os.path.exists(d):
|
||||
@ -104,26 +119,85 @@ def create_index(version, mods, gunpacks):
|
||||
with open(f"{MODPACK_DIR}/modrinth.index.json", 'w') as f:
|
||||
f.write('\n'.join(lines))
|
||||
|
||||
def send_qq_message(message):
|
||||
try:
|
||||
url = f"{QQ_API_URL}/send_group_msg"
|
||||
data = json.dumps({
|
||||
"group_id": int(QQ_GROUP_ID),
|
||||
"message": message
|
||||
}).encode('utf-8')
|
||||
req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application/json'})
|
||||
with urllib.request.urlopen(req, timeout=10) as response:
|
||||
result = json.loads(response.read().decode('utf-8'))
|
||||
if result.get('status') == 'ok':
|
||||
log("QQ notification sent successfully")
|
||||
else:
|
||||
log(f"QQ notification failed: {result}")
|
||||
except Exception as e:
|
||||
log(f"Failed to send QQ message: {e}")
|
||||
|
||||
def main():
|
||||
log("Starting minimal modpack synchronization")
|
||||
os.makedirs(STATE_DIR, exist_ok=True)
|
||||
|
||||
prev_mods, prev_excluded = load_previous_state()
|
||||
included, excluded, gunpacks = sync_minimal_pack()
|
||||
|
||||
current = open(VERSION_FILE).read().strip() if os.path.exists(VERSION_FILE) else "0.0.0"
|
||||
parts = current.split('.')
|
||||
new_version = f"{parts[0]}.{parts[1]}.{int(parts[2]) + 1}"
|
||||
open(VERSION_FILE, 'w').write(new_version)
|
||||
|
||||
# Check for changes
|
||||
mods_changed = set(included) != set(prev_mods) if prev_mods else True
|
||||
|
||||
if mods_changed:
|
||||
log(f"Mod changes detected: {len(included)} mods now")
|
||||
|
||||
# Find added and removed mods
|
||||
prev_set = set(prev_mods) if prev_mods else set()
|
||||
curr_set = set(included)
|
||||
added_mods = curr_set - prev_set
|
||||
removed_mods = prev_set - curr_set
|
||||
|
||||
# Create change summary
|
||||
change_summary = []
|
||||
if added_mods:
|
||||
change_summary.append(f"新增模组 ({len(added_mods)}):\n" + "\n".join([f" + {m}" for m in list(added_mods)[:5]]))
|
||||
if len(added_mods) > 5:
|
||||
change_summary.append(f" ... 及其他 {len(added_mods) - 5} 个")
|
||||
if removed_mods:
|
||||
change_summary.append(f"移除模组 ({len(removed_mods)}):\n" + "\n".join([f" - {m}" for m in list(removed_mods)[:5]]))
|
||||
if len(removed_mods) > 5:
|
||||
change_summary.append(f" ... 及其他 {len(removed_mods) - 5} 个")
|
||||
|
||||
# Send QQ notification
|
||||
qq_message = f"""📦 整合包更新公告
|
||||
━━━━━━━━━━━━━━━━━━━━━━
|
||||
版本: v{new_version}
|
||||
模组数量: {len(included)} 个 (+{len(added_mods) if added_mods else 0} -{len(removed_mods) if removed_mods else 0})
|
||||
枪包数量: {len(gunpacks)} 个
|
||||
━━━━━━━━━━━━━━━━━━━━━━
|
||||
"""
|
||||
if change_summary:
|
||||
qq_message += "\n".join(change_summary) + "\n"
|
||||
qq_message += """━━━━━━━━━━━━━━━━━━━━━━
|
||||
📥 下载地址: ssh://git@192.168.2.106:220/jianf/servermods.git
|
||||
或联系管理员获取最新整合包"""
|
||||
|
||||
send_qq_message(qq_message)
|
||||
|
||||
create_index(new_version, included, gunpacks)
|
||||
open(VERSION_FILE, 'w').write(new_version)
|
||||
|
||||
with open(f"{STATE_DIR}/mods.json", 'w') as f:
|
||||
f.write('\n'.join(included))
|
||||
with open(f"{STATE_DIR}/excluded_mods.json", 'w') as f:
|
||||
json.dump(excluded, f)
|
||||
with open(f"{STATE_DIR}/gunpacks.json", 'w') as f:
|
||||
f.write('\n'.join(gunpacks))
|
||||
|
||||
log(f"Version: {new_version}")
|
||||
log(f"Mods included: {len(included)} (excluded {len(excluded)} client-only)")
|
||||
log(f"Mods: {len(included)} included, {len(excluded)} excluded (client-only)")
|
||||
log(f"Gunpacks: {len(gunpacks)}")
|
||||
|
||||
log("Updating git repository")
|
||||
|
||||
Reference in New Issue
Block a user