koishi-plugin-node-async-bot-all 2.0.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands.d.ts +6 -7
- package/lib/fun.d.ts +4 -4
- package/lib/index.d.ts +0 -4
- package/lib/index.js +30 -93
- package/package.json +2 -2
- package/res/list.txt +0 -18
- package/res/slk//344/271/235/345/260/276/347/213/220/345/205/245/345/234/272.slk +0 -0
- package/res/slk//344/271/235/345/260/276/347/213/220/345/205/245/345/234/272/345/234/243/350/257/236/350/212/202.slk +0 -0
- package/res/slk//344/271/235/345/260/276/347/213/220/345/205/245/345/234/272/346/227/240SCP.slk +0 -0
- package/res/slk//345/217/226/346/266/210/346/240/270/345/274/271.slk +0 -0
- package/res/slk//346/227/240079.slk +0 -0
- package/res/slk//346/240/270/345/274/27190/347/247/222.slk +0 -0
- package/res/slk//346/240/270/345/274/271/351/207/215/346/226/260/345/220/257/345/212/25030/347/247/222.slk +0 -0
- package/res/slk//346/240/270/345/274/271/351/207/215/346/226/260/345/220/257/345/212/25050/347/247/222.slk +0 -0
- package/res/slk//350/275/273/346/224/26610/345/210/206/351/222/237.slk +0 -0
- package/res/slk//350/275/273/346/224/26615/345/210/206/351/222/237.slk +0 -0
- package/res/slk//350/275/273/346/224/2661/345/210/206/351/222/237.slk +0 -0
- package/res/slk//350/275/273/346/224/26630/347/247/222.slk +0 -0
- package/res/slk//350/275/273/346/224/2665/345/210/206/351/222/237.slk +0 -0
- package/res/slk//350/275/273/346/224/266/345/205/263/351/227/255.slk +0 -0
- package/res/slk//350/277/207/350/275/2753/345/210/206/344/271/2131.slk +0 -0
- package/res/slk//350/277/207/350/275/2753/345/210/206/344/271/2132.slk +0 -0
- package/res/slk//350/277/207/350/275/2753/345/210/206/344/271/2133.slk +0 -0
- package/res/slk//350/277/207/350/275/275/345/220/257/345/212/250.slk +0 -0
package/lib/commands.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
export declare function getServer(ctx: Context, session:
|
|
3
|
-
export declare function getStatus(ctx: Context, session:
|
|
4
|
-
export declare function getRandom(ctx: Context, session:
|
|
5
|
-
export declare function getInfo(ctx: Context, session:
|
|
6
|
-
export declare function getRW(ctx: Context, session:
|
|
7
|
-
export declare function getCASSIE(ctx: Context, session: any, name: string): Promise<object>;
|
|
1
|
+
import { Context, Session } from 'koishi';
|
|
2
|
+
export declare function getServer(ctx: Context, session: Session): Promise<Object>;
|
|
3
|
+
export declare function getStatus(ctx: Context, session: Session): Promise<Object>;
|
|
4
|
+
export declare function getRandom(ctx: Context, session: Session, min: number, max: number): Promise<Object>;
|
|
5
|
+
export declare function getInfo(ctx: Context, session: Session): Promise<Object>;
|
|
6
|
+
export declare function getRW(ctx: Context, session: Session): Promise<Object>;
|
package/lib/fun.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Context } from "koishi";
|
|
2
|
-
|
|
1
|
+
import { Context, FlatPick } from "koishi";
|
|
2
|
+
import Analytics from "@koishijs/plugin-analytics";
|
|
3
|
+
export declare function getSystemUsage(): Promise<Object>;
|
|
3
4
|
export declare function getHongKongTime(): string;
|
|
4
5
|
export declare function fetchWithTimeout(url: string, options: {}, timeout: number, log: any): Promise<Response>;
|
|
5
6
|
export declare function readInfoFile(ctx: Context): Promise<string>;
|
|
6
|
-
export declare function getAudioPath(name: string): Promise<string>;
|
|
7
|
-
export declare function getAudioList(): Promise<string[]>;
|
|
8
7
|
export declare function formatTimestampDiff(start: number, end: number): string;
|
|
8
|
+
export declare function getMsgCount(array: FlatPick<Analytics.Message, "type" | "count">[]): Object;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
// src/locales/zh-CN.yml
|
|
34
34
|
var require_zh_CN = __commonJS({
|
|
35
35
|
"src/locales/zh-CN.yml"(exports2, module2) {
|
|
36
|
-
module2.exports = { commands: { cx: { description: "查询服务器当前人数。", messages: { msg: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", msgNoPlayer: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}\n请稍后重试。", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", unknown: "未知错误。", host: "没有到主机的路由。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败(2)。" } }
|
|
36
|
+
module2.exports = { commands: { cx: { description: "查询服务器当前人数。", messages: { msg: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", msgNoPlayer: "{time}\n【服务器当前人数】\n➣ {version}:{players}\n➣ 协议版本:{protocol}\n进服指南请在群公告中查看。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}\n请稍后重试。", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", unknown: "未知错误。", host: "没有到主机的路由。" } }, status: { description: "查询机器人状态。", messages: { msg: "{time}\n--- 系统状态 ---\n系统名称:{name}\nCPU使用率:{cpu}\n内存使用率:{memory}\n--- 机器人状态 ---\n昨日收/发消息数量:{msgCount}\n机器人版本:{version}\n运行时间:{online}", failed: "{time}\n状态获取失败。" } }, random: { description: "随机数生成器。", usage: "缺少参数时默认生成 0-10000 的随机数。\n使用示例:", examples: "random 1 128 生成1到128范围的随机数", messages: { msg: "{time}\n生成的随机数:{data}" } }, info: { description: "查询机器人信息。", messages: { msg: "{data}", failed: "{time}\n读取信息失败。" } }, rw: { description: "随机名言名句。", messages: { msg: "{time}\n{data}", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败(2)。" } } } };
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -47,6 +47,9 @@ __export(src_exports, {
|
|
|
47
47
|
usage: () => usage
|
|
48
48
|
});
|
|
49
49
|
module.exports = __toCommonJS(src_exports);
|
|
50
|
+
var import_koishi2 = require("koishi");
|
|
51
|
+
|
|
52
|
+
// src/commands.ts
|
|
50
53
|
var import_koishi = require("koishi");
|
|
51
54
|
|
|
52
55
|
// src/fun.ts
|
|
@@ -149,16 +152,6 @@ async function readInfoFile(ctx) {
|
|
|
149
152
|
return info;
|
|
150
153
|
}
|
|
151
154
|
__name(readInfoFile, "readInfoFile");
|
|
152
|
-
async function getAudioPath(name2) {
|
|
153
|
-
return import_path.default.resolve(__dirname, "..") + import_path.default.sep + "res" + import_path.default.sep + "slk" + import_path.default.sep + name2 + ".slk";
|
|
154
|
-
}
|
|
155
|
-
__name(getAudioPath, "getAudioPath");
|
|
156
|
-
async function getAudioList() {
|
|
157
|
-
const listPath = import_path.default.resolve(__dirname, "..") + import_path.default.sep + "res" + import_path.default.sep + "list.txt";
|
|
158
|
-
const data = await import_fs.default.promises.readFile(listPath, "utf-8");
|
|
159
|
-
return data.split(/\r?\n/).filter(Boolean);
|
|
160
|
-
}
|
|
161
|
-
__name(getAudioList, "getAudioList");
|
|
162
155
|
function formatTimestampDiff(start, end) {
|
|
163
156
|
const diff = Math.abs(end - start);
|
|
164
157
|
const hours = Math.floor(diff / 3600);
|
|
@@ -167,9 +160,21 @@ function formatTimestampDiff(start, end) {
|
|
|
167
160
|
return `${hours} 时 ${minutes} 分 ${seconds} 秒`;
|
|
168
161
|
}
|
|
169
162
|
__name(formatTimestampDiff, "formatTimestampDiff");
|
|
163
|
+
function getMsgCount(array) {
|
|
164
|
+
let receive = 0;
|
|
165
|
+
let send = 0;
|
|
166
|
+
array.forEach((item) => {
|
|
167
|
+
if (item.type == "receive") {
|
|
168
|
+
receive = receive + item.count;
|
|
169
|
+
} else {
|
|
170
|
+
send = send + item.count;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return { "receive": receive, "send": send };
|
|
174
|
+
}
|
|
175
|
+
__name(getMsgCount, "getMsgCount");
|
|
170
176
|
|
|
171
177
|
// src/commands.ts
|
|
172
|
-
var import_fs2 = __toESM(require("fs"));
|
|
173
178
|
async function getServer(ctx, session) {
|
|
174
179
|
const log = ctx.logger("cx");
|
|
175
180
|
log.info(`Got: {"form":"${session.event.guild.id}","user":"${session.event.user.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message.id}"}`);
|
|
@@ -274,7 +279,7 @@ async function getStatus(ctx, session) {
|
|
|
274
279
|
"success": 1
|
|
275
280
|
};
|
|
276
281
|
} else {
|
|
277
|
-
|
|
282
|
+
const msgCount = getMsgCount(await ctx.database.get("analytics.message", { date: import_koishi.Time.getDateNumber() - 1 }, ["type", "count"]));
|
|
278
283
|
msg = {
|
|
279
284
|
"time": time,
|
|
280
285
|
"name": vMsg["name"],
|
|
@@ -282,8 +287,10 @@ async function getStatus(ctx, session) {
|
|
|
282
287
|
"memory": vMsg["memory"],
|
|
283
288
|
"online": formatTimestampDiff(
|
|
284
289
|
Number((await ctx.database.get("botData", "uptime"))[0].data),
|
|
285
|
-
session.event.timestamp.toString().substring(0, 10)
|
|
290
|
+
Number(session.event.timestamp.toString().substring(0, 10))
|
|
286
291
|
),
|
|
292
|
+
"msgCount": `${msgCount["receive"]}/${msgCount["send"]}`,
|
|
293
|
+
"version": (await ctx.database.get("botData", "version"))[0].data,
|
|
287
294
|
"success": 0
|
|
288
295
|
};
|
|
289
296
|
}
|
|
@@ -381,81 +388,23 @@ async function getRW(ctx, session) {
|
|
|
381
388
|
return msg;
|
|
382
389
|
}
|
|
383
390
|
__name(getRW, "getRW");
|
|
384
|
-
async function getCASSIE(ctx, session, name2) {
|
|
385
|
-
const log = ctx.logger("cassie");
|
|
386
|
-
log.info(`Got: {"form":"${session.event.guild.id}","user":"${session.event.user.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message.id}"}`);
|
|
387
|
-
let msg;
|
|
388
|
-
const time = getHongKongTime();
|
|
389
|
-
const list = await getAudioList();
|
|
390
|
-
if (name2 == void 0) {
|
|
391
|
-
msg = {
|
|
392
|
-
"time": time,
|
|
393
|
-
"data": list.map((fruit, index) => `${index + 1}. ${fruit}`).join("\n"),
|
|
394
|
-
"success": 1
|
|
395
|
-
};
|
|
396
|
-
log.info("Sent: .msg");
|
|
397
|
-
log.info(msg);
|
|
398
|
-
return msg;
|
|
399
|
-
} else if (list.includes(name2)) {
|
|
400
|
-
const fullPath = await getAudioPath(name2);
|
|
401
|
-
try {
|
|
402
|
-
const fileBuffer = await import_fs2.default.promises.readFile(fullPath);
|
|
403
|
-
log.info(fullPath);
|
|
404
|
-
if (!ctx.silk.isSilk(fileBuffer)) {
|
|
405
|
-
msg = {
|
|
406
|
-
"time": time,
|
|
407
|
-
"success": 2
|
|
408
|
-
};
|
|
409
|
-
log.error("发送失败:非 .slk 文件");
|
|
410
|
-
log.info("Sent: .failed");
|
|
411
|
-
log.info(msg);
|
|
412
|
-
} else {
|
|
413
|
-
log.info("Sent: A audio file.");
|
|
414
|
-
msg = {
|
|
415
|
-
"time": time,
|
|
416
|
-
"data": fileBuffer,
|
|
417
|
-
"success": 0
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
return msg;
|
|
421
|
-
} catch (e) {
|
|
422
|
-
msg = {
|
|
423
|
-
"time": time,
|
|
424
|
-
"success": 2
|
|
425
|
-
};
|
|
426
|
-
log.error("发送失败:" + e.message);
|
|
427
|
-
log.info("Sent: .failed");
|
|
428
|
-
log.info(msg);
|
|
429
|
-
return msg;
|
|
430
|
-
}
|
|
431
|
-
} else {
|
|
432
|
-
msg = {
|
|
433
|
-
"time": time,
|
|
434
|
-
"success": 3
|
|
435
|
-
};
|
|
436
|
-
log.info("Sent: .unknown");
|
|
437
|
-
log.info(msg);
|
|
438
|
-
return msg;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
__name(getCASSIE, "getCASSIE");
|
|
442
391
|
|
|
443
392
|
// package.json
|
|
444
|
-
var version = "2.0
|
|
393
|
+
var version = "2.2.0";
|
|
445
394
|
|
|
446
395
|
// src/index.ts
|
|
447
|
-
var inject = ["
|
|
396
|
+
var inject = ["database"];
|
|
448
397
|
var name = "node-async-bot-all";
|
|
449
398
|
var usage = "这是一个私有插件。";
|
|
450
|
-
var Config =
|
|
451
|
-
|
|
452
|
-
timeout:
|
|
399
|
+
var Config = import_koishi2.Schema.intersect([
|
|
400
|
+
import_koishi2.Schema.object({
|
|
401
|
+
timeout: import_koishi2.Schema.number().default(8e3).description("超时时间(毫秒)")
|
|
453
402
|
}).description("基础"),
|
|
454
|
-
|
|
455
|
-
cxAPI:
|
|
403
|
+
import_koishi2.Schema.object({
|
|
404
|
+
cxAPI: import_koishi2.Schema.string().default("https://api.tasaed.top/get/minecraftServer/").description("查询 API")
|
|
456
405
|
}).description("查询"),
|
|
457
|
-
|
|
458
|
-
rwAPI:
|
|
406
|
+
import_koishi2.Schema.object({
|
|
407
|
+
rwAPI: import_koishi2.Schema.string().default("https://api.tasaed.top/rw/").description("随机文本 API")
|
|
459
408
|
}).description("随机文本")
|
|
460
409
|
]).description("基础设置");
|
|
461
410
|
function apply(ctx) {
|
|
@@ -514,18 +463,6 @@ function apply(ctx) {
|
|
|
514
463
|
return session.text(".failed2", rw);
|
|
515
464
|
}
|
|
516
465
|
});
|
|
517
|
-
ctx.command("cassie [名称:string]").action(async ({ session }, name2) => {
|
|
518
|
-
const cassie = await getCASSIE(ctx, session, name2);
|
|
519
|
-
if (cassie["success"] == 0) {
|
|
520
|
-
return import_koishi.h.audio(cassie["data"], "audio/silk");
|
|
521
|
-
} else if (cassie["success"] == 1) {
|
|
522
|
-
return [`${session.text(".msg", cassie)}`];
|
|
523
|
-
} else if (cassie["success"] == 2) {
|
|
524
|
-
return session.text(".failed", cassie);
|
|
525
|
-
} else {
|
|
526
|
-
return session.text(".unknown", cassie);
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
466
|
}
|
|
530
467
|
__name(apply, "apply");
|
|
531
468
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-node-async-bot-all",
|
|
3
3
|
"description": "NodeAsync Bot插件(自用)",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"contributors": [
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@koishijs/plugin-help": "^2.4.5",
|
|
35
35
|
"koishi": "^4.18.7",
|
|
36
|
-
"
|
|
36
|
+
"@koishijs/plugin-database-sqlite": "^4.6.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/res/list.txt
DELETED
|
Binary file
|
|
Binary file
|
package/res/slk//344/271/235/345/260/276/347/213/220/345/205/245/345/234/272/346/227/240SCP.slk
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|