-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkoishi-plugin-misc.js
50 lines (41 loc) · 1.47 KB
/
koishi-plugin-misc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const {User} = require("koishi-core");
const {segment} = require("koishi-utils");
module.exports.name = 'project-e-misc'
module.exports.apply = (ctx) => {
ctx.command("project-e/fakemsg [...rest]","假聊天记录",)
.action((ctx, ...rest) => fakemsg(ctx,rest));;
ctx.command("project-e/tts [text]","文本转语音",)
.action((ctx,text) => tts(ctx,text));
}
function tts (ctx,text) {
return "[CQ:tts,text="+text+"]";
}
function fakemsg(ctx,rest) {
let msgnode = "[";
if (rest.length === 0 ){
return "格式 [QQ号] [昵称] [信息] ... [QQ号] [昵称] [信息]"
}
if (rest.length % 3 !== 0) {
return "缺少参数";
}
for (let i = 0; i < rest.length; i = i + 3) {
if (i+3 === rest.length) {
msgnode = msgnode +
"{\"type\": \"node\",\"data\": {\"name\": \""+rest[i+1]+"\",\"uin\": \""
+rest[i]+"\",\"content\": \""+rest[i+2]+"\"}}]"
} else {
msgnode = msgnode +
"{\"type\": \"node\",\"data\": {\"name\": \""+rest[i+1]+"\",\"uin\": \""
+rest[i]+"\",\"content\": \""+rest[i+2]+"\"}},"
}
}
try {
ctx.session.bot.$sendGroupForwardMsg(ctx.session.groupId,
JSON.parse(segment.unescape(msgnode))
).then().catch(function (e) {
return "[X]捕捉到异常\n " + e.toString();
})
}catch (e) {
return "[X]捕捉到异常\n " + e.toString();
}
}