细节优化
This commit is contained in:
parent
0b33fc9153
commit
d085cb4d10
|
@ -17,7 +17,6 @@
|
||||||
# 3.0.1
|
# 3.0.1
|
||||||
|
|
||||||
* 支持多账号,支持协议端:go-cqhttp
|
* 支持多账号,支持协议端:go-cqhttp
|
||||||
* 由于完全删除了 OICQ,并且内置 `segment`,若插件缺少 OICQ,需删除 `import { segment } from "oicq"`
|
|
||||||
|
|
||||||
# 3.0.0
|
# 3.0.0
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ Yunzai 应用端,支持多账号,支持协议端:go-cqhttp、ComWeChat、G
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
- 基于 [Miao-Yunzai](../../../../yoimiya-kokomi/Miao-Yunzai) 改造,需要同时安装 [miao-plugin](../../../../yoimiya-kokomi/miao-plugin)
|
- 基于 [Miao-Yunzai](../../../../yoimiya-kokomi/Miao-Yunzai) 改造,需要同时安装 [miao-plugin](../../../../yoimiya-kokomi/miao-plugin)
|
||||||
- 由于完全删除了 OICQ,并且内置 `segment`,若插件缺少 OICQ,需删除 `import { segment } from "oicq"`
|
|
||||||
- 开发文档:[docs 分支](../../tree/docs)
|
- 开发文档:[docs 分支](../../tree/docs)
|
||||||
|
|
||||||
## TRSS-Yunzai 后续计划
|
## TRSS-Yunzai 后续计划
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
import fs from "node:fs"
|
||||||
|
|
||||||
|
const segment = new class segment {
|
||||||
|
custom(type, data) {
|
||||||
|
for (const i in data) {
|
||||||
|
switch (typeof data[i]) {
|
||||||
|
case "string":
|
||||||
|
if ((i == "file" || data[i].match(/^file:\/\//)) && fs.existsSync(data[i].replace(/^file:\/\//, "")))
|
||||||
|
data[i] = `base64://${fs.readFileSync(data[i].replace(/^file:\/\//, "")).toString("base64")}`
|
||||||
|
break
|
||||||
|
case "object":
|
||||||
|
if (Buffer.isBuffer(data[i]))
|
||||||
|
data[i] = `base64://${data[i].toString("base64")}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { type, ...data }
|
||||||
|
}
|
||||||
|
image(file) {
|
||||||
|
return this.custom("image", { file })
|
||||||
|
}
|
||||||
|
at(qq, name) {
|
||||||
|
return this.custom("at", { qq, name })
|
||||||
|
}
|
||||||
|
record(file) {
|
||||||
|
return this.custom("record", { file })
|
||||||
|
}
|
||||||
|
video(file) {
|
||||||
|
return this.custom("video", { file })
|
||||||
|
}
|
||||||
|
reply(id, text, qq, time, seq) {
|
||||||
|
return this.custom("reply", { id, text, qq, time, seq })
|
||||||
|
}
|
||||||
|
face(id) {
|
||||||
|
return this.custom("face", { id })
|
||||||
|
}
|
||||||
|
share(url, title, content, image) {
|
||||||
|
return this.custom("share", { url, title, content, image })
|
||||||
|
}
|
||||||
|
music(type, id, url, audio, title) {
|
||||||
|
return this.custom("music", { type, id, url, audio, title })
|
||||||
|
}
|
||||||
|
poke(qq) {
|
||||||
|
return this.custom("poke", { qq })
|
||||||
|
}
|
||||||
|
gift(qq, id) {
|
||||||
|
return this.custom("gift", { qq, id })
|
||||||
|
}
|
||||||
|
cardimage(file, minwidth, minheight, maxwidth, maxheight, source, icon) {
|
||||||
|
return this.custom("cardimage", { file, minwidth, minheight, maxwidth, maxheight, source, icon })
|
||||||
|
}
|
||||||
|
tts(text) {
|
||||||
|
return this.custom("tts", { text })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { segment }
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"name": "oicq",
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.js"
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import lodash from "lodash"
|
||||||
import cfg from "../config/config.js"
|
import cfg from "../config/config.js"
|
||||||
import plugin from "./plugin.js"
|
import plugin from "./plugin.js"
|
||||||
import schedule from "node-schedule"
|
import schedule from "node-schedule"
|
||||||
|
import { segment } from "oicq"
|
||||||
import chokidar from "chokidar"
|
import chokidar from "chokidar"
|
||||||
import moment from "moment"
|
import moment from "moment"
|
||||||
import path from "node:path"
|
import path from "node:path"
|
||||||
|
@ -12,39 +13,7 @@ import Runtime from "./runtime.js"
|
||||||
|
|
||||||
/** 全局变量 plugin */
|
/** 全局变量 plugin */
|
||||||
global.plugin = plugin
|
global.plugin = plugin
|
||||||
|
global.segment = segment
|
||||||
function toSegment(type, data) {
|
|
||||||
for (const i in data)
|
|
||||||
if (data[i])
|
|
||||||
switch (typeof data[i]) {
|
|
||||||
case "string":
|
|
||||||
if ((i == "file" || data[i].match(/^file:\/\//)) && fs.existsSync(data[i].replace(/^file:\/\//, "")))
|
|
||||||
data[i] = `base64://${fs.readFileSync(data[i].replace(/^file:\/\//, "")).toString("base64")}`
|
|
||||||
break
|
|
||||||
case "object":
|
|
||||||
if (Buffer.isBuffer(data[i]))
|
|
||||||
data[i] = `base64://${data[i].toString("base64")}`
|
|
||||||
}
|
|
||||||
return { type, ...data }
|
|
||||||
}
|
|
||||||
|
|
||||||
global.segment = {
|
|
||||||
image: file => toSegment("image", { file }),
|
|
||||||
at: (qq, name) => toSegment("at", { qq, name }),
|
|
||||||
record: file => toSegment("record", { file }),
|
|
||||||
video: file => toSegment("video", { file }),
|
|
||||||
reply: (id, text, qq, time, seq) => toSegment("reply", { id, text, qq, time, seq }),
|
|
||||||
face: id => toSegment("face", { id }),
|
|
||||||
share: (url, title, content, image) => toSegment("share", { url, title, content, image }),
|
|
||||||
music: (type, id, url, audio, title) => toSegment("music", { type, id, url, audio, title }),
|
|
||||||
poke: qq => toSegment("poke", { qq }),
|
|
||||||
gift: (qq, id) => toSegment("gift", { qq, id }),
|
|
||||||
xml: (data, resid) => toSegment("xml", { data, resid }),
|
|
||||||
json: (data, resid) => toSegment("json", { data, resid }),
|
|
||||||
cardimage: (file, minwidth, minheight, maxwidth, maxheight, source, icon) => toSegment("cardimage", { file, minwidth, minheight, maxwidth, maxheight, source, icon }),
|
|
||||||
tts: text => toSegment("tts", { text }),
|
|
||||||
custom: toSegment,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载插件
|
* 加载插件
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"node-fetch": "^3.3.1",
|
"node-fetch": "^3.3.1",
|
||||||
"node-schedule": "^2.1.1",
|
"node-schedule": "^2.1.1",
|
||||||
"node-xlsx": "^0.23.0",
|
"node-xlsx": "^0.23.0",
|
||||||
|
"oicq": "link:lib/modules/oicq",
|
||||||
"pm2": "^5.3.0",
|
"pm2": "^5.3.0",
|
||||||
"puppeteer": "^20.8.0",
|
"puppeteer": "^20.8.0",
|
||||||
"redis": "^4.6.7",
|
"redis": "^4.6.7",
|
||||||
|
|
Loading…
Reference in New Issue