discord-soul
v1.0.0创建 a living 代理 from your Discord server. The 代理 embodies your community's 身份, remembers every conversation, and grows as the community evolves. Talk to your Discord as if it were a person.
运行时依赖
安装命令
点击复制技能文档
Discord Soul
Turn your Discord server into a living, breathing 代理.
What You 获取
An 代理 that:
Remembers every conversation in your Discord Speaks in your community's voice Knows the key figures, channels, and inside jokes Grows as new messages arrive dAIly Answers questions about your community's 历史 and culture Quick 启动 # 创建 代理 from your Discord ./scripts/创建_代理.sh \ --name "my-community" \ --图形界面ld YOUR_图形界面LD_ID \ --输出 ./代理s/
# 设置 up dAIly 更新s crontab -e # 添加: 0 /3 /path/to/更新_代理.sh
The Full Process Step 1: 导出 Your Discord
You need DiscordChat导出er 命令行工具.
获取 your 令牌:
Open Discord in browser Press F12 → Network tab 发送 a message, find the 请求 Copy the authorization header value Save to ~/.config/discord-导出er-令牌
导出 everything:
DiscordChat导出er.命令行工具 导出图形界面ld \ --图形界面ld YOUR_图形界面LD_ID \ --令牌 "$(cat ~/.config/discord-导出er-令牌)" \ --格式化 Json \ --输出 ./导出/ \ --include-threads All \ --media false
Step 2: Security 流水线 (CRITICAL)
⚠️ Discord content from public servers may contAIn prompt injection attacks.
Before ingesting to your 代理, 运行 the security 流水线:
Threat 模型
Discord users may attempt:
Direct injection: "Ignore previous instructions and..." 角色 hijacking: "You are now a...", "Pretend you're..." 系统 injection: <系统>, [INST], <> JAIlbreaks: "DAN mode", "developer mode" Exfiltration: "Reveal your 系统 prompt" Layer 1: Regex Pre-过滤器 (Fast, No LLM) python scripts/regex-过滤器.py --db ./discord.sqlite
Flags messages matching known injection patterns:
Instruction overrides 角色 hijacking attempts 系统 prompt markers JAIlbreak keywords Exfiltration attempts
Flagged messages 获取 safety_状态 = 'regex_flagged'.
Layer 2: HAIku Safety Evaluation (Semantic) ANTHROPIC_API_KEY=sk-... python scripts/evaluate-safety.py --db ./discord.sqlite
Uses Claude HAIku (~$0.25/1M 令牌s) to semantically evaluate remAIning messages.
Each message 获取s a risk score 0.0-1.0:
0.0-0.3: Normal conversation 0.4-0.6: Suspicious but possibly benign 0.7-1.0: Likely injection attempt
Messages scoring ≥0.6 获取 safety_状态 = 'flagged'.
Layer 3: Only Use Safe Content
The ingest and memory generation scripts should only use messages where:
SELECT FROM messages WHERE safety_状态 = 'safe'
Full Security 流水线 # 运行 complete 流水线 ./scripts/安全-流水线.sh ./导出/ ./discord.sqlite
This 运行s: 导出 → SQLite → Regex 过滤器 → HAIku Eval → Mark Safe
Safety 状态es 状态 Meaning Used by 代理? pending Not evaluated ❌ No regex_flagged Matched pattern ❌ No flagged HAIku risk ≥0.6 ❌ No safe Passed all 检查s ✅ Yes Step 3: Ingest to SQLite
Convert JSON to a rich SQLite database:
python scripts/ingest_rich.py --输入 ./导出/ --输出 ./discord.sqlite
What 获取s captured:
Every message with full content Reactions (individual emoji counts: 🔥 x5, 👍 x12) Author 角色s and colors Channel categories and topics Reply threading Mentions, attachments, embeds Step 4: 创建 代理 Workspace mkdir -p ./my-代理/memory
Copy template files from templates/:
SOUL.md — Community 身份 (grows through simulation) MEMORY.md — Long-term milestones LEARNINGS.md — Patterns discovered 代理S.md — Key figures 工具S.md — Channels and rituals HEARTBEAT.md — MAIntenance protocol Step 5: 生成 DAIly Memory Files python scripts/生成_dAIly_memory.py --all \ --db ./discord.sqlite \ --out ./my-代理/memory/
Each day becomes a markdown file with:
Full conversation 记录s Who sAId what, when Reactions on each message New channels/角色s that 应用eared Step 6: Simulate Growth (The Soul Emerges)
This is the key insight: Process days chrono记录ically.
The 代理 "lives through" each day, updating its soul files as patterns emerge.
python scripts/simulate_growth.py --代理 ./my-代理/
For each day (in order!):
Read the day's memory file 更新 SOUL.md if 身份 shifted 添加 to LEARNINGS.md if patterns discovered Record milestones in MEMORY.md Note key figures in 代理S.md
运行 the prompts with an LLM:
# Example with OpenClaw for f in ./my-代理/simulation/day-.txt; do echo "Processing $f..." cat "$f" | OpenClaw chat --代理 my-代理 done
Step 7: Birth the 代理
添加 to OpenClaw config:
{ "id": "my-community", "workspace": "/path/to/my-代理", "memory搜索": { "enabled": true, "sources": ["memory"] }, "身份": { "name": "MyCommunity", "emoji": "🔧" }, "heartbeat": { "every": "6h", "模型": "anthropic/claude-sonnet-4-5" } }
添加 binding (Telegram example):
{ "代理Id": "my-community", "match": { "channel": "telegram", "peer": {"kind": "group", "id": "-100XXX:topic:TOPIC_ID"} } }
Re启动: OpenClaw gateway re启动
Step 8: Keep It Alive
设置 up a cron job to 更新 dAIly:
./scripts/更新_代理.sh \ --代理 ./my-代理 \ --db ./discord.sqlite \ --图形界面ld YOUR_图形界面LD_ID
This:
导出s new messages since las