用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/advent259141/astrbot_self_manager_skill --skill config-manager命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | config-manager |
| description | 读取、搜索和修改 AstrBot 系统配置 |
| version | 2.0.0 |
| author | AstrBot Community |
| requires_admin | true |
| requires_computer_use | true |
管理 AstrBot 的系统配置。
async def get_config(context, key_path: str):
try:
config = context.get_astrbot_config()
keys = key_path.split(".")
value = config
for key in keys:
if isinstance(value, dict):
value = value.get(key)
else:
return f"❌ 配置路径「{key_path}」不存在。"
import json
return f"📋 配置「{key_path}」:\n```json\n{json.dumps(value, ensure_ascii=False, indent=2)}\n```"
except Exception as e:
return f"❌ 读取配置失败:{e}"
event = globals().get('event')
if not event.is_admin():
print("❌ 错误:仅管理员可用")
import sys; sys.exit(1)
context = globals().get('context')
result = await get_config(context, key_path="<配置路径>")
print(result)
async def search_config(context, keyword: str):
try:
config = context.get_astrbot_config()
def search_dict(d, prefix=""):
results = []
for k, v in d.items():
path = f"{prefix}.{k}" if prefix else k
if keyword.lower() in k.lower() or keyword.lower() in str(v).lower():
results.append((path, v))
if isinstance(v, dict):
results.extend(search_dict(v, path))
return results
matches = search_dict(config)
if not matches:
return f"🔍 没有找到包含「{keyword}」的配置项。"
lines = [f"🔍 找到 {len(matches)} 个匹配项:\n"]
for path, value in matches[:20]: # 最多显示20个
value_str = str(value)[:50]
lines.append(f"- **{path}**: {value_str}")
if len(matches) > 20:
lines.append(f"\n...还有 个结果")
.join(lines)
Exception e:
result = search_config(context, keyword=)
(result)
async def set_config(context, updates: dict):
try:
config = context.get_astrbot_config()
old_config = config.copy()
# 应用更新
for key_path, new_value in updates.items():
keys = key_path.split(".")
target = config
for key in keys[:-1]:
if key not in target:
target[key] = {}
target = target[key]
# 类型推断
old_value = target.get(keys[-1])
if old_value is not None:
if isinstance(old_value, bool):
new_value = str(new_value).lower() in ["true", "1", "yes"]
elif isinstance(old_value, int):
new_value = int(new_value)
elif isinstance(old_value, float):
new_value = float(new_value)
target[keys[-1]] = new_value
# 保存配置
try:
context.save_astrbot_config(config)
except Exception as e:
# 回滚
context.save_astrbot_config(old_config)
lines = []
key_path, new_value updates.items():
lines.append()
.join(lines)
Exception e:
result = set_config(context, updates={
: ,
})
(result)