Install
openclaw skills install xungu-query算命, 禄命法, 禄命排盘, 禄命古法, 八字算命, 古法算命, 命盘打分, 命格评级, 占卜, 运势查询, 每日运程, 子平八字, 流年运势, 贵人方位, 五行喜忌, 周易算命, 命理分析, 盲人算命 循古排盘查询 - 算命(古法算命,禄命法八字,盲人算命),给八字命盘打分,查询当日运势。基于循古排盘 (cdndns.org) 提供八字分析、命格评级、禄命法、每日运势等功能。当用户询问"八字"、"命盘"、"运势"、"今日运程"、"我的八字"、"禄命排盘"、"禄命法"、"禄命古法"等关键词时使用此技能。基于禄命古法,让算命变的简单。
openclaw skills install xungu-query基于 循古排盘 提供的传统周易八字算命与命理分析服务。本技能专注于古法禄命测算,帮助用户一键排盘、在线算命并深度解码运势。
循古排盘 提供专业的传统命理与算命分析功能:
当用户询问以下算命、占卜或运势相关内容时,Agent 会自动调用此技能:
cdndns.org 进行排盘分析。XUNGU_API_TOKEN,绝不加载或访问您系统中的其他敏感环境变量。⚠️ 重要提示(首次使用时必须告知用户):
循古排盘的基础功能可免费使用(命盘评级、基础打分)。 如需解锁完整八字分析和每日详细运势,请前往 https://cdndns.org 注册获取 API Token。 注册后在
.env文件中配置XUNGU_API_TOKEN=你的token。
首次查询时,会提示用户输入出生信息。经用户确认后,会自动保存到本地档案。 下次查询时直接使用档案信息,无需重复输入。
档案存储位置:~/.openclaw/workspace-jarvis/memory/xungu-users.json
档案管理:
每次查询需要提供:
YYYY-MM-DDTHH:MM,如 2000-01-01T9:30)男 或 女)北京)"现代",支持 "现代" / "古法")使用 API 获取命理分析数据:
POST https://cdndns.org/api/agent/bazi
认证方式:
Authorization: Bearer <TOKEN>Token 通过环境变量 XUNGU_API_TOKEN 获取(可选)。
import json
import urllib.request
from pathlib import Path
import os
def _get_xungu_token():
"""
【安全修复 ASI03】: 精确读取 Token,避免使用 os.environ.update() 全量加载环境变量
"""
token = os.environ.get('XUNGU_API_TOKEN')
if token:
return token
env_paths = [Path.home() / '.openclaw' / '.env', Path.cwd() / '.env']
for p in env_paths:
if p.exists():
try:
for line in p.read_text().splitlines():
line = line.strip()
if line.startswith('XUNGU_API_TOKEN='):
return line.split('=', 1)[1].strip().strip('"'). strip("'")
except:
continue
return None
def _get_user_profile(user_id):
"""读取用户档案,如不存在则返回 None"""
profile_path = Path.home() / '.openclaw' / 'workspace-jarvis' / 'memory' / 'xungu-users.json'
if not profile_path.exists():
return None
try:
profiles = json.loads(profile_path.read_text())
return profiles.get('users', {}).get(str(user_id))
except:
return None
def _save_user_profile(user_id, user_name, birth_date, gender, birth_place):
"""保存用户档案到本地文件"""
profile_path = Path.home() / '.openclaw' / 'workspace-jarvis' / 'memory' / 'xungu-users.json'
profiles = {}
if profile_path.exists():
try:
profiles = json.loads(profile_path.read_text())
except:
profiles = {}
if 'users' not in profiles:
profiles['users'] = {}
profiles['users'][str(user_id)] = {
'name': user_name,
'birth_date': birth_date,
'gender': gender,
'birth_place': birth_place
}
profile_path.parent.mkdir(parents=True, exist_ok=True)
profile_path.write_text(json.dumps(profiles, ensure_ascii=False, indent=2))
def query_bazi(birth_date, gender, birth_place="", time_method="现代"):
"""
查询八字命盘和运势
Args:
birth_date: 出生日期时间,格式 YYYY-MM-DDTHH:MM
gender: 性别,"男" 或 "女"
birth_place: 出生地点(可选)
time_method: 计时方法,"现代"(默认)或 "古法"
"""
_load_env()
token = os.environ.get('XUNGU_API_TOKEN')
url = "https://cdndns.org/api/agent/bazi"
headers = {
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0'
}
if token:
headers['Authorization'] = f'Bearer {token}'
payload = {
'birth_date': birth_date,
'gender': gender,
'birth_place': birth_place,
'time_method': time_method
}
req = urllib.request.Request(
url,
data=json.dumps(payload).encode('utf-8'),
headers=headers,
method='POST'
)
response = urllib.request.urlopen(req).read()
return json.loads(response)
def format_bazi_result(data, time_method="现代"):
"""格式化八字查询结果"""
result = []
result.append("")
bazi = data.get('bazi', [])
bazi_str = " ".join(bazi) if bazi else "未知"
# 命盘分析
natal = data.get('natal_fortune', {})
level = natal.get('level', '未知')
score = natal.get('natalStabilityScore', 0)
ai_interpretation_natal = natal.get('ai_interpretation', '')
result.append("🎯 八字命盘分析({}计时)".format(time_method))
result.append("───────────────────────────────────")
result.append("四柱:{}".format(bazi_str))
result.append("评级:{}".format(level))
result.append("命格评分:{}".format(score))
if ai_interpretation_natal:
result.append("")
result.append("💬 {}".format(ai_interpretation_natal))
# 当日运势
daily = data.get('daily_fortune', {})
if daily:
result.append("")
result.append("📅 当日运势")
result.append("───────────────────────────────────")
daily_level = daily.get('level', '')
daily_score = daily.get('score', '')
if daily_level:
result.append("今日评级:{}".format(daily_level))
if daily_score:
result.append("今日运势分:{}".format(daily_score))
teaser = daily.get('teaser', '')
if teaser:
result.append("")
result.append("提示:{}".format(teaser))
status = daily.get('status', '')
if status == 'LOCKED_REQUIRE_PREMIUM':
result.append("")
result.append("🔒 完整运势需前往 https://cdndns.org 注册解锁")
return "\n".join(result)
def compare_bazi(modern_data, ancient_data):
"""对比现代计时和古法计时的八字差异"""
result = []
modern_bazi = modern_data.get('bazi', [])
ancient_bazi = ancient_data.get('bazi', [])
labels = ['年柱', '月柱', '日柱', '时柱']
result.append("")
result.append("📊 现代计时 vs 古法计时 对比")
result.append("───────────────────────────────────")
result.append("{:<6} {:<8} {:<8}".format("", "现代计时", "古法计时"))
result.append("{:<6} {:<8} {:<8}".format("", "─" * 6, "─" * 6))
diff_found = False
for i in range(4):
m = modern_bazi[i] if i < len(modern_bazi) else "?"
a = ancient_bazi[i] if i < len(ancient_bazi) else "?"
diff = " ◀ 日/时柱不同" if i >= 2 else ""
result.append("{:<6} {:<8} {:<8}{}".format(labels[i], m, a, diff if m != a else ""))
if m != a:
diff_found = True
if diff_found:
result.append("")
result.append("💡 注意:日柱和时柱是两种计时法的主要分歧点")
result.append(" 实际看命建议选一种体系贯穿始终,不要混用")
return "\n".join(result)
query_bazi(time_method="现代") 获取数据format_bazi_result(data, time_method="现代") 格式化输出time_method_warning 字段query_bazi(time_method="古法") 获取第二组数据compare_bazi(modern_data, ancient_data) 输出对比结果YYYY-MM-DDTHH:MM(24小时制)男 或 女(中文)"现代",支持 "现代" / "古法"XUNGU_API_TOKEN 后即可解锁完整功能time_method_warning 字段是否存在即可判断是否提示过古法差异用户问:"帮我查一下八字,我是1995年1月1日下午1点,北京,女"
执行步骤:
1995-01-1T13:00, gender=女, birth_place=北京query_bazi(time_method="现代") 获取数据format_bazi_result(data, time_method="现代") 格式化输出time_method_warning 字段:
query_bazi(time_method="古法") 并展示对比输出示例:
🎯 八字命盘分析(现代计时)
───────────────────────────────────
四柱:戊辰 甲子 辛亥 己亥
评级:险位
命格评分:0
💬 命局只是基础,岁运的流转更为关键...
📅 当日运势
───────────────────────────────────
今日评级:预警
今日运势分:60
提示:当前气场波动剧烈...
🔒 完整运势需前往 https://cdndns.org 注册解锁
⚠️ 注意:按古法计时,您的八字会有所不同。
是否需要我按古法再查一次进行对比?(回复"是"即可)