chore: collect latest dingTalk feishu docs
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
def find_project_root():
|
||||
"""向上查找项目根目录(包含 data/ 目录的最顶层)"""
|
||||
@@ -56,12 +57,59 @@ def find_dws():
|
||||
def find_lark_cli():
|
||||
"""查找 lark-cli"""
|
||||
import shutil
|
||||
root = find_project_root()
|
||||
ext = ".exe" if os.name == "nt" else ""
|
||||
|
||||
local = os.path.join(root, "tools", "lark-cli", "lark-cli" + ext)
|
||||
if os.path.isfile(local):
|
||||
return local
|
||||
|
||||
found = shutil.which("lark-cli")
|
||||
if found:
|
||||
return found
|
||||
print("ERROR: 找不到 lark-cli,请运行 npm install -g @larksuite/cli", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def load_groups():
|
||||
"""读取群配置,优先使用 data/group_config.json,失败时返回默认群。"""
|
||||
default = {
|
||||
"dc战略问题研究院": "cidoUneRB4Db8TAXaTrKxkQAw==",
|
||||
"创新组": "cidMuM+itt5PeY7xNSWsv3M0g==",
|
||||
"天龙计划X小游戏矩阵": "cid/Vb3hSjdv4sIIs8Fp7sC4g==",
|
||||
}
|
||||
path = os.path.join(find_project_root(), "data", "group_config.json")
|
||||
if not os.path.isfile(path):
|
||||
return default
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
raw = json.load(f).get("groups", {})
|
||||
groups = {}
|
||||
for name, value in raw.items():
|
||||
if isinstance(value, dict):
|
||||
cid = value.get("cid") or value.get("id")
|
||||
else:
|
||||
cid = value
|
||||
if cid:
|
||||
groups[name] = cid
|
||||
return groups or default
|
||||
except Exception as e:
|
||||
print(f"WARN: 读取群配置失败,使用默认配置: {e}", file=sys.stderr)
|
||||
return default
|
||||
|
||||
def normalize_messages(messages):
|
||||
"""兼容 list 和按群 dict 两种历史消息文件格式。"""
|
||||
if isinstance(messages, dict):
|
||||
return messages
|
||||
grouped = {}
|
||||
if not isinstance(messages, list):
|
||||
return grouped
|
||||
for msg in messages:
|
||||
if not isinstance(msg, dict):
|
||||
continue
|
||||
group = msg.get("group") or msg.get("groupName") or msg.get("openConversationId") or "未分组"
|
||||
grouped.setdefault(group, []).append(msg)
|
||||
return grouped
|
||||
|
||||
# 常用路径
|
||||
PROJECT_ROOT = find_project_root()
|
||||
DATA_DIR = os.path.join(PROJECT_ROOT, "data")
|
||||
|
||||
Reference in New Issue
Block a user