import {Context,Schema} from 'koishi'
import { h } from "koishi"
export const name = 'zhouyi'
export interface Config {}
export const using = []
export const Config: Schema < Config > = Schema.object({})
export async function apply(ctx: Context) {
ctx.command("算一卦").action(async ({session}, ...args) => {
await session.send((String(h("quote", {id: (session.messageId)})) + kaisi(args[0])));
})
}
function kaisi(xx) {
var yis = Math.floor(Math.random() * 10 + 1);
var ers = Math.floor(Math.random() * 10 + 1);
var sans = Math.floor(Math.random() * 10 + 1);
var sis = Math.floor(Math.random() * 10 + 1);
var wus = Math.floor(Math.random() * 10 + 1);
var lius = Math.floor(Math.random() * 10 + 1);
var yy = yis % 2;
var ee = ers % 2;
var ss = sans % 2;
var sisi = sis % 2;
var ww = wus % 2;
var ll = lius % 2;
var gua = "1";
var shangs = "";
var xias = "";
var shang = "";
var xia = "";
var jie = "";
//上卦
if (yy == 0 & ee == 0 & ss == 0) {
shang = "上乾";
shangs = 1
} else if (yy == 1 & ee == 1 & ss == 1) {
shang = "上坤";
shangs = 2
} else if (yy == 0 & ee == 1 & ss == 1) {
shang = "上艮";
shangs = 3
} else if (yy == 0 & ee == 0 & ss == 1) {
shang = "上巽";
shangs = 4
} else if (yy == 0 & ee == 1 & ss == 0) {
shang = "上离";
shangs = 5
} else if (yy == 1 & ee == 0 & ss == 0) {
shang = "上兑";
shangs = 6
} else if (yy == 1 & ee == 1 & ss == 0) {
shang = "上震";
shangs = 7
} else if (yy == 1 & ee == 0 & ss == 1) {
shang = "上坎";
shangs = 8
}
//下卦
if (sisi == 0 & ww == 0 & ll == 0) {
xia = "下乾";
xias = 1
} else if (sisi == 1 & ww == 1 & ll == 1) {
xia = "下坤";
xias = 2
} else if (sisi == 0 & ww == 1 & ll == 1) {
xia = "下艮";
xias = 3
} else if (sisi == 0 & ww == 0 & ll == 1) {
xia = "下巽";
xias = 4
} else if (sisi == 0 & ww == 1 & ll == 0) {
xia = "下离";
xias = 5
} else if (sisi == 1 & ww == 0 & ll == 0) {
xia = "下兑";
xias = 6
} else if (sisi == 1 & ww == 1 & ll == 0) {
xia = "下震";
xias = 7
} else if (sisi == 1 & ww == 0 & ll == 1) {
xia = "下坎";
xias = 8
}
//六爻变化
if (yy == 0) {
yy = "██████"
} else {
yy = "██ ██"
}
if (ee == 0) {
ee = "██████"
} else {
ee = "██ ██"
}
if (ss == 0) {
ss = "██████"
} else {
ss = "██ ██"
}
if (sisi == 0) {
sisi = "██████"
} else {
sisi = "██ ██"
}
if (ww == 0) {
ww = "██████"
} else {
ww = "██ ██"
}
if (ll == 0) {
ll = "██████"
} else {
ll = "██ ██"
}
//四字卦和详解的链接
if (shangs == 1 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-01.htm";
gua = "\t\t 一\n\t\t 乾为天\n天地之初,乾元之始.\n亢龙有侮,适可而止."
} else if (shangs == 2 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-02.htm";
gua = "\t\t 二\n\t\t 坤为地\n万物滋生,柔顺和祥.\n西南得朋,东北失明."
} else if (shangs == 8 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-03.htm";
gua = "\t\t 三\n\t\t 水雷屯\n天造昏屯,气运未顺.\n若欲显成,快刀斩麻."
} else if (shangs == 3 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-04.htm";
gua = "\t\t 四\n\t\t 山水蒙\n同蒙求我,及时未晚.\n蒙蒙茫茫,机难多求."
} else if (shangs == 8 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-05.htm";
gua = "\t\t 五\n\t\t 水天需\n努力进取,成功可期.\n男有机缘,女遇红鸾."
} else if (shangs == 1 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-06.htm";
gua = "\t\t 六\n\t\t 天水讼\n争争夺夺,两败俱伤.\n宜和忌讼,谦忍为上."
} else if (shangs == 2 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-07.htm";
gua = "\t\t 七\n\t\t 地水师\n防人争强,成功可望.\n为师若重,逢凶化吉."
} else if (shangs == 8 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-08.htm";
gua = "\t\t 八\n\t\t 水地比\n顺风驶帆,轻而易举.\n宜亲诸侯,可行方国."
} else if (shangs == 4 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-09.htm";
gua = "\t\t 九\n\t\t 风天小畜\n毁誉参半,不宜急功.\n若能持稳,拨云见日."
} else if (shangs == 1 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-10.htm";
gua = "\t\t 十\n\t\t 天泽履\n逢凶化吉,遇难成祥.\n努力实践,奋斗可成."
} else if (shangs == 2 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-11.htm";
gua = "\t\t 十一\n\t\t 地天泰\n持盈保泰,功无不克.\n光耀门闾,三元及第."
} else if (shangs == 1 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-12.htm";
gua = "\t\t 十二\n\t\t 天地否\n陷阱叠叠,困难重重.\n能忍天磨,可成铁汉."
} else if (shangs == 1 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-13.htm";
gua = "\t\t 十三\n\t\t 天火同人\n光明正直,灵光显现.\n无私无偏,仙人指引."
} else if (shangs == 5 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-14.htm";
gua = "\t\t 十四\n\t\t 火天大有\n探囊取物,易如反掌.\n宜防体肤,易生变化."
} else if (shangs == 2 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-15.htm";
gua = "\t\t 十五\n\t\t 地山谦\n谦恭有礼,和气生财.\n若能始终,功无不克."
} else if (shangs == 7 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-16.htm";
gua = "\t\t 十六\n\t\t 雷地豫\n事豫则立,不豫则败.\n做事之初,未雨绸缪."
} else if (shangs == 6 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-17.htm";
gua = "\t\t 十七\n\t\t 泽雷随\n随遇则安,因人成事.\n虽有小变,尚不为凶."
} else if (shangs == 3 & xias == 4) {
jie = "https://m.k366.com/gua/1200000-11-18.htm";
gua = "\t\t 十八\n\t\t 山风蛊\n小人谗言,未可尽信.\n执迷不悟,害己害人."
} else if (shangs == 2 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-19.htm";
gua = "\t\t 十九\n\t\t 地泽临\n临事莫惧,刚柔并进.\n大器晚成,为时不晚."
} else if (shangs == 4 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-20.htm";
gua = "\t\t 二十\n\t\t 风地观\n观察入微,静中求智.\n时来运转,成就非凡."
} else if (shangs == 5 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-21.htm";
gua = "\t\t 二十一\n\t\t 火雷噬嗑\n大咀大嚼,久旱逢甘.\n但防口角,乐中有悲."
} else if (shangs == 3 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-22.htm";
gua = "\t\t 二十二\n\t\t 山火贲\n装饰之美,表里难一.\n若为感情,喜气之兆."
} else if (shangs == 3 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-23.htm";
gua = "\t\t 二十三\n\t\t 山地剥\n阴人琐碎,防不胜防.\n剥落之际.提防失财."
} else if (shangs == 2 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-24.htm";
gua = "\t\t 二十四\n\t\t 地雷复\n由剥而复,光芒在露.\n阳刚势强,伉俪宜防."
} else if (shangs == 1 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-25.htm";
gua = "\t\t 二十五\n\t\t 天雷无妄\n飞来横祸,功亦有过.\n闲事莫问,闭门无咎."
} else if (shangs == 3 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-26.htm";
gua = "\t\t 二十六\n\t\t 山天大畜\n气势磅礡,势如破竹.\n大大储蓄,财喜并至."
} else if (shangs == 3 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-27.htm";
gua = "\t\t 二十七\n\t\t 山雷颐\n口食自给,尚有余粮.\n求访贤人,财运滋生."
} else if (shangs == 6 & xias == 4) {
jie = "https://m.k366.com/gua/1200000-11-28.htm";
gua = "\t\t 二十八\n\t\t 泽风大过\n卦如其义,大过之秋.\n如欲降过,非财莫取."
} else if (shangs == 8 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-29.htm";
gua = "\t\t 二十九\n\t\t 坎为水\n似显未见,实不易现.\n一轮明月,蜃楼一现."
} else if (shangs == 5 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-30.htm";
gua = "\t\t 三十\n\t\t 离为火\n光芒四射,神佛护佑.\n小心火烛,家道安宁."
} else if (shangs == 6 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-31.htm";
gua = "\t\t 三十一\n\t\t 泽山咸\n初生之犊,不畏巨虎.\n萌芽出土,更需维护."
} else if (shangs == 7 & xias == 4) {
jie = "https://m.k366.com/gua/1200000-11-32.htm";
gua = "\t\t 三十二\n\t\t 雷风恒\n持之以恒,其事可成.\n不焦不躁,自得其福."
} else if (shangs == 1 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-33.htm";
gua = "\t\t 三十三\n\t\t 天山遁\n适可而止,动不如静.\n恶运初始,有才无命."
} else if (shangs == 7 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-34.htm";
gua = "\t\t 三十四\n\t\t 雷天大壮\n大壮之年,勤能补拙.\n置产兴业,家运康宁."
} else if (shangs == 5 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-35.htm";
gua = "\t\t 三十五\n\t\t 火地晋\n勤俭持家,才帛自得.\n高官厚爵,指日可待."
} else if (shangs == 2 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-36.htm";
gua = "\t\t 三十六\n\t\t 地火明夷\n明而见伤,即合即离.\n似喜非喜,顺中有变."
} else if (shangs == 4 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-37.htm";
gua = "\t\t 三十七\n\t\t 风火家人\n有喜化灾,天福增寿.\n无喜解厄,防患未然."
} else if (shangs == 5 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-38.htm";
gua = "\t\t 三十八\n\t\t 火泽睽\n众目睽睽,静观其变.\n易遭人妒,非是庸才."
} else if (shangs == 8 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-39.htm";
gua = "\t\t 三十九\n\t\t 水山蹇\n山水相连,其灾必显.\n解厄行运,为靠己至."
} else if (shangs == 7 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-40.htm";
gua = "\t\t 四十\n\t\t 雷水解\n改过之心,坚心不变.\n恶运已过,防微杜渐."
} else if (shangs == 3 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-41.htm";
gua = "\t\t 四十一\n\t\t 山泽损\n损失难免,应防扩渐.\n行善积德,其危不现."
} else if (shangs == 4 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-42.htm";
gua = "\t\t 四十二\n\t\t 风雷益\n逢春朽木,似不常见.\n春风得意,宜防虐缘."
} else if (shangs == 6 & xias == 1) {
jie = "https://m.k366.com/gua/1200000-11-43.htm";
gua = "\t\t 四十三\n\t\t 择天夬\n六月九月,脱出凶险.\n初运不济,终来福显."
} else if (shangs == 1 & xias == 4) {
jie = "https://m.k366.com/gua/1200000-11-44.htm";
gua = "\t\t 四十四\n\t\t 天风姤\n桃花之缘,处处可见.\n惟此邂姤,最为难解."
} else if (shangs == 6 & xias == 2) {
jie = "https://m.k366.com/gua/1200000-11-45.htm";
gua = "\t\t 四十五\n\t\t 泽地萃\n人才荟萃,草木皆长.\n鲤鱼成龙,群臣扶首."
} else if (shangs == 2 & xias == 4) {
jie = "https://m.k366.com/gua/1200000-11-46.htm";
gua = "\t\t 四十六\n\t\t 地风升\n旭日初上,王者有亨.\n刚中而应,贤才进升."
} else if (shangs == 6 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-47.htm";
gua = "\t\t 四十七\n\t\t 泽水困\n虎落平阳,犬鼠相戏.\n困苦挣扎,无功乏力."
} else if (shangs == 8 & xias == 4) {
jie = "https://m.k366.com/gua/1200000-11-48.htm";
gua = "\t\t 四十八\n\t\t 水风井\n井中之水,用之不竭.\n勤勉持本,生生不息."
} else if (shangs == 6 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-49.htm";
gua = "\t\t 四十九\n\t\t 泽火革\n改革方针,宜先准备.\n虎头鼠尾,变化万千."
} else if (shangs == 4 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-50.htm";
gua = "\t\t 五十\n\t\t 风火鼎\n三足鼎立,其功甚巨.\n用人为才,三分天下."
} else if (shangs == 7 & xias == 7) {
jie = "https://m.k366.com/gua/1200000-11-51.htm";
gua = "\t\t 五十一\n\t\t 震为雷\n四海名扬,其人必震.\n雷声隆隆,可想其成."
} else if (shangs == 3 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-52.htm";
gua = "\t\t 五十二\n\t\t 艮为山\n一山一山,峰脉相连.\n若得助力,非有神机."
} else if (shangs == 4 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-53.htm";
gua = "\t\t 五十三\n\t\t 风山渐\n高山险阻,毅力可冲.\n若贵人助,展翅飞腾."
} else if (shangs == 7 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-54.htm";
gua = "\t\t 五十四\n\t\t 雷泽归妹\n虽有姻缘,但防生变.\n老夫少妻,不可久也."
} else if (shangs == 7 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-55.htm";
gua = "\t\t 五十五\n\t\t 雷火丰\n光芒再现,其功有年.\n贵在有情,更要惜缘."
} else if (shangs == 5 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-56.htm";
gua = "\t\t 五十六\n\t\t 火山旅\n漂泊未定,多事之秋.\n小人举现,远离他乡."
} else if (shangs == 4 & xias == 4) {
jie = "https://m.k366.com/gua/1200000-11-57.htm";
gua = "\t\t 五十七\n\t\t 巽为风\n及时之雨,甘之如饴.\n得风庇助,船可行也."
} else if (shangs == 6 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-58.htm";
gua = "\t\t 五十八\n\t\t 兑为泽\n妻财之初,如水如鱼.\n减少奋斗,二三十年."
} else if (shangs == 4 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-59.htm";
gua = "\t\t 五十九\n\t\t 风水涣\n聚散离合,循环消长.\n君臣同心,使涣为合."
} else if (shangs == 8 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-60.htm";
gua = "\t\t 六十\n\t\t 水泽节\n明哲保身,节而不奢.\n君子谋成,舍己求仁."
} else if (shangs == 4 & xias == 6) {
jie = "https://m.k366.com/gua/1200000-11-61.htm";
gua = "\t\t 六十一\n\t\t 风泽中孚\n外强中刚,阴生其中.\n信而有实,无有咎也."
} else if (shangs == 7 & xias == 3) {
jie = "https://m.k366.com/gua/1200000-11-62.htm";
gua = "\t\t 六十二\n\t\t 雷山小过\n飞鸟遗音,宜下忌上.\n安於本来,不为过失."
} else if (shangs == 8 & xias == 5) {
jie = "https://m.k366.com/gua/1200000-11-63.htm";
gua = "\t\t 六十三\n\t\t 水火既济\n水火相继,终自得利.\n人止知足,守成不易."
} else if (shangs == 5 & xias == 8) {
jie = "https://m.k366.com/gua/1200000-11-64.htm";
gua = "\t\t 六十四\n\t\t 火水未济\n初为不利,险而之义.\n再得时机,终可得济."
}
//拼接返回
if(xx==null){
var all_gua = `你心中所念卦象为:\n\t ${shang} ${xia}\n\t${yy}\n\t${ee}\n\t${ss}\n\t${sisi}\n\t${ww}\n\t${ll}\n${gua}\n详解:\n${jie}`
}else{
var all_gua = `你心中所念${xx}卦象为:\n\t ${shang} ${xia}\n\t${yy}\n\t${ee}\n\t${ss}\n\t${sisi}\n\t${ww}\n\t${ll}\n${gua}\n详解:\n${jie}`
}
return all_gua
}
2 个赞
我还是第一次见到有人在求插件版块发帖但自己带了代码的
不会发布!大佬能帮忙发布一下吗
1 个赞
太秀了
1 个赞
我也想用上这个插件!
1 个赞
谢谢你,看到这个if else血压已经开始飙升了
1 个赞
布尔位运算()
1 个赞
哈哈哈!希望大佬能改改然后发布!
1 个赞
整理干净了
加了点私货()
import { Context, Schema , h ,Random} from 'koishi'
import {createHash} from 'crypto'
export const name = 'zhouyi'
export interface Config {}
export const using = []
export const Config: Schema < Config > = Schema.object({})
export async function apply(ctx: Context) {
ctx.command("zhouyi <reason:string>")
.alias("算一卦")
.action(async ({session},reason) => {
await session.send((String(h("quote", {id: (session.messageId)})) + suangua(session.userId,reason)));
})
}
// 八卦表
const guaxiang = [
{id:1,name:"乾",unicode:"☰",bool:[true,true,true]},
{id:2,name:"坤",unicode:"☷",bool:[false,false,false]},
{id:3,name:"艮",unicode:"☶",bool:[true,false,false]},
{id:4,name:"巽",unicode:"☴",bool:[true,true,false]},
{id:5,name:"离",unicode:"☲",bool:[true,false,true]},
{id:6,name:"兑",unicode:"☱",bool:[false,true,true]},
{id:7,name:"震",unicode:"☳",bool:[false,false,true]},
{id:8,name:"坎",unicode:"☶",bool:[true,false,false]},
]
// 八八六十四,解卦矩阵
const jieRex = [
[ // 1乾
{id:1 ,word:"乾为天\n天地之初,乾元之始。\n亢龙有侮,适可而止。"},
{id:12,word:"天地否\n陷阱叠叠,困难重重。\n能忍天磨,可成铁汉。"},
{id:33,word:"天山遁\n适可而止,动不如静。\n恶运初始,有才无命。"},
{id:44,word:"天风姤\n桃花之缘,处处可见。\n惟此邂姤,最为难解。"},
{id:13,word:"天火同人\n光明正直,灵光显现。\n无私无偏,仙人指引。"},
{id:10,word:"天泽履\n逢凶化吉,遇难成祥。\n努力实践,奋斗可成。"},
{id:25,word:"天雷无妄\n飞来横祸,功亦有过。\n闲事莫问,闭门无咎。"},
{id:6 ,word:"天水讼\n争争夺夺,两败俱伤。\n宜和忌讼,谦忍为上。"},
],
[ // 2坤
{id:11,word:"地天泰\n持盈保泰,功无不克。\n光耀门闾,三元及第。"},
{id:2 ,word:"坤为地\n万物滋生,柔顺和祥。\n西南得朋,东北失明。"},
{id:15,word:"地山谦\n谦恭有礼,和气生财。\n若能始终,功无不克。"},
{id:46,word:"地风升\n旭日初上,王者有亨。\n刚中而应,贤才进升。"},
{id:36,word:"地火明夷\n明而见伤,即合即离。\n似喜非喜,顺中有变。"},
{id:19,word:"地泽临\n临事莫惧,刚柔并进。\n大器晚成,为时不晚。"},
{id:24,word:"地雷复\n由剥而复,光芒在露。\n阳刚势强,伉俪宜防。"},
{id:7 ,word:"地水师\n防人争强,成功可望。\n为师若重,逢凶化吉。"},
],
[ // 3艮
{id:26,word:"山天大畜\n气势磅礡,势如破竹。\n大大储蓄,财喜并至。"},
{id:23,word:"山地剥\n阴人琐碎,防不胜防。\n剥落之际.提防失财。"},
{id:52,word:"艮为山\n一山一山,峰脉相连。\n若得助力,非有神机。"},
{id:18,word:"山风蛊\n小人谗言,未可尽信。\n执迷不悟,害己害人。"},
{id:22,word:"山火贲\n装饰之美,表里难一。\n若为感情,喜气之兆。"},
{id:41,word:"山泽损\n损失难免,应防扩渐。\n行善积德,其危不现。"},
{id:27,word:"山雷颐\n口食自给,尚有余粮。\n求访贤人,财运滋生。"},
{id:4 ,word:"山水蒙\n同蒙求我,及时未晚。\n蒙蒙茫茫,机难多求。"},
],
[ // 4巽
{id:9 ,word:"风天小畜\n毁誉参半,不宜急功。\n若能持稳,拨云见日。"},
{id:20,word:"风地观\n观察入微,静中求智。\n时来运转,成就非凡。"},
{id:53,word:"风山渐\n高山险阻,毅力可冲。\n若贵人助,展翅飞腾。"},
{id:57,word:"巽为风\n及时之雨,甘之如饴。\n得风庇助,船可行也。"},
{id:37,word:"风火家人\n有喜化灾,天福增寿。\n无喜解厄,防患未然。"},
{id:61,word:"风泽中孚\n外强中刚,阴生其中。\n信而有实,无有咎也。"},
{id:42,word:"风雷益\n逢春朽木,似不常见。\n春风得意,宜防虐缘。"},
{id:59,word:"风水涣\n聚散离合,循环消长。\n君臣同心,使涣为合。"},
],
[ // 5离
{id:14,word:"火天大有\n探囊取物,易如反掌。\n宜防体肤,易生变化。"},
{id:35,word:"火地晋\n勤俭持家,才帛自得。\n高官厚爵,指日可待。"},
{id:56,word:"火山旅\n漂泊未定,多事之秋。\n小人举现,远离他乡。"},
{id:50,word:"火风鼎\n三足鼎立,其功甚巨。\n用人为才,三分天下。"},
{id:30,word:"离为火\n光芒四射,神佛护佑。\n小心火烛,家道安宁。"},
{id:38,word:"火泽睽\n众目睽睽,静观其变。\n易遭人妒,非是庸才。"},
{id:21,word:"火雷噬嗑\n大咀大嚼,久旱逢甘。\n但防口角,乐中有悲。"},
{id:64,word:"火水未济\n初为不利,险而之义。\n再得时机,终可得济。"},
],
[ // 6兑
{id:43,word:"择天夬\n六月九月,脱出凶险。\n初运不济,终来福显。"},
{id:45,word:"泽地萃\n人才荟萃,草木皆长。\n鲤鱼成龙,群臣扶首。"},
{id:31,word:"泽山咸\n初生之犊,不畏巨虎。\n萌芽出土,更需维护。"},
{id:28,word:"泽风大过\n卦如其义,大过之秋。\n如欲降过,非财莫取。"},
{id:49,word:"泽火革\n改革方针,宜先准备。\n虎头鼠尾,变化万千。"},
{id:59,word:"兑为泽\n妻财之初,如水如鱼。\n减少奋斗,二三十年。"},
{id:17,word:"泽雷随\n随遇则安,因人成事。\n虽有小变,尚不为凶。"},
{id:47,word:"泽水困\n虎落平阳,犬鼠相戏。\n困苦挣扎,无功乏力。"},
],
[ // 7震
{id:34,word:"雷天大壮\n大壮之年,勤能补拙。\n置产兴业,家运康宁。"},
{id:16,word:"雷地豫\n事豫则立,不豫则败。\n做事之初,未雨绸缪。"},
{id:62,word:"雷山小过\n飞鸟遗音,宜下忌上。\n安於本来,不为过失。"},
{id:32,word:"雷风恒\n持之以恒,其事可成。\n不焦不躁,自得其福。"},
{id:55,word:"雷火丰\n光芒再现,其功有年。\n贵在有情,更要惜缘。"},
{id:54,word:"雷泽归妹\n虽有姻缘,但防生变。\n老夫少妻,不可久也。"},
{id:51,word:"震为雷\n四海名扬,其人必震。\n雷声隆隆,可想其成。"},
{id:40,word:"雷水解\n改过之心,坚心不变。\n恶运已过,防微杜渐。"},
],
[ // 8坎
{id:5 ,word:"水天需\n努力进取,成功可期。\n男有机缘,女遇红鸾。"},
{id:8 ,word:"水地比\n顺风驶帆,轻而易举。\n宜亲诸侯,可行方国。"},
{id:39,word:"水山蹇\n山水相连,其灾必显。\n解厄行运,为靠己至。"},
{id:48,word:"水风井\n井中之水,用之不竭。\n勤勉持本,生生不息。"},
{id:63,word:"水火既济\n水火相继,终自得利。\n人止知足,守成不易。"},
{id:60,word:"水泽节\n明哲保身,节而不奢。\n君子谋成,舍己求仁。"},
{id:3 ,word:"水雷屯\n天造昏屯,气运未顺。\n若欲显成,快刀斩麻。"},
{id:29,word:"坎为水\n似显未见,实不易现。\n一轮明月,蜃楼一现。"},
]
]
// 汉语数字表
const ncmap = ['零','一','二','三','四','五','六','七','八','九'] as const
// 2位数字转汉字
function num2Char(n:number){
const cut = Math.floor(Math.abs(n))%100
const gewei = cut%10
const shiwei = Math.floor(cut/10)
if(shiwei){
if(gewei){
return ncmap[shiwei]+'十'+ncmap[gewei]
}else{
return ncmap[shiwei]+'十'
}
}else{
return ncmap[gewei]
}
}
function suangua(id:string,reason:string = '') {
let guaToday:number;
if(!reason){
const hash = createHash('sha256')
hash.update(id)
hash.update(new Date().getDate().toString())
guaToday = parseInt(hash.digest('hex').substring(0,3),16) %64
}else{
guaToday = Random.int(1,65)
}
const shang = guaxiang[guaToday%8]
const xia = guaxiang[Math.floor(guaToday/8)]
const jie = jieRex[shang.id-1][xia.id-1]
const cnum = num2Char(jie.id)
const link = `https://m.k366.com/gua/1200000-11-${jie.id<10?('0'+jie.id):jie.id}.htm`
const reasult =
`你心中所念${reason?reason:'今日'}卦象为:\n`+
`上${shang.name}下${xia.name}\n`+
`${shang.unicode}\n`+ // 暂定,用长条也不是不行
`${xia.unicode}\n`+
`${link}\n`+
`详解:\n`+
`${cnum}\n`+
`${jie.word}\n`
return reasult
}
2 个赞
谢谢!大佬!只要能用就行
3 个赞
错误的,这个代码把我也整懵了
2 个赞
用我的()
3 个赞