koishi-plugin-node-async-bot-all 2.14.0 → 2.16.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 +1 -1
- package/lib/index.js +17 -18
- package/package.json +1 -1
package/lib/commands.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export declare function getRW(ctx: Context, session: Session): Promise<Object>;
|
|
|
13
13
|
export declare function getBA(ctx: Context, session: Session): Promise<Number>;
|
|
14
14
|
export declare function serverTest(ctx: Context, session: Session): Promise<Object>;
|
|
15
15
|
export declare function getSteam(ctx: Context, session: Session, id: number): Promise<Object>;
|
|
16
|
-
export declare function getMeme(ctx: Context, session: Session): Promise<
|
|
16
|
+
export declare function getMeme(ctx: Context, session: Session, count: number): Promise<Number>;
|
package/lib/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
// src/locales/zh-CN.yml
|
|
35
35
|
var require_zh_CN = __commonJS({
|
|
36
36
|
"src/locales/zh-CN.yml"(exports2, module2) {
|
|
37
|
-
module2.exports = { commands: { cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", 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}", error: "执行错误。", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, servertest: { description: "Ping服务器。", messages: { msg: "{time}\n== Ping {host} ==\n状态:{alive}\n丢包率:{packetLoss}\n返回IP:{ip}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\nPing 失败:{data}" } }, steamid: { description: "将 Steam 好友码(SteamID 3)转为 SteamID 64。", messages: { msg: "{time}\n转换结果:{data}", failed: "{time}\n转换失败:{data}", null: "参数 Steam 好友码(SteamID 3) 不得为空。", command: "执行错误。" } }, meme: { description: "群友的怪话!", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。", error: "执行错误。" } } } };
|
|
37
|
+
module2.exports = { commands: { cxgame: { description: "查询服务器当前人数。", messages: { msg: "{time}{list}\n进服指南请在群公告中查看。", list: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 玩家列表:{list}\n➣ 备注:{note}", listNoPlayer: "【MC 服务器 {count}】\n➣ {version}:{players}\n➣ 备注:{note}", listFailed: "【MC 服务器 {count}】\n➣ 查询失败:{data}\n➣ 请稍后重试。", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\n查询失败:{data}", timeout: "请求超时。", timeout2: "响应超时。", fewData: "服务端返回的数据过少。", close: "服务器已关闭。", error: "执行错误。", 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}", error: "执行错误。", failed1: "{time}\n获取失败(1)。", failed2: "{time}\n获取失败({data})。" } }, randomba: { description: "随机BA图。", messages: { msg: "{quote}{image}", wait: "{quote}{time}\n请等待图片上传(可能较慢)。" } }, servertest: { description: "Ping服务器。", messages: { msg: "{time}\n== Ping {host} ==\n状态:{alive}\n丢包率:{packetLoss}\n返回IP:{ip}", forbidden: "{time}\n此指令不允许在本群使用。", failed: "{time}\nPing 失败:{data}" } }, steamid: { description: "将 Steam 好友码(SteamID 3)转为 SteamID 64。", messages: { msg: "{time}\n转换结果:{data}", failed: "{time}\n转换失败:{data}", null: "参数 Steam 好友码(SteamID 3) 不得为空。", command: "执行错误。" } }, meme: { description: "群友的怪话!", messages: { msg: "{quote}{time}\n{image}\n{title}", failed: "{quote}{time}\n获取失败:{data}", forbidden: "{quote}{time}\n此指令不允许在本群使用。", error: "执行错误。", e: "未能发送消息。" } } } };
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -591,7 +591,7 @@ async function getSteam(ctx, session, id) {
|
|
|
591
591
|
return msg;
|
|
592
592
|
}
|
|
593
593
|
__name(getSteam, "getSteam");
|
|
594
|
-
async function getMeme(ctx, session) {
|
|
594
|
+
async function getMeme(ctx, session, count) {
|
|
595
595
|
const log = ctx.logger("getMeme");
|
|
596
596
|
log.info(`Got: {"form":"${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
597
597
|
let msg;
|
|
@@ -602,13 +602,14 @@ async function getMeme(ctx, session) {
|
|
|
602
602
|
msg = {
|
|
603
603
|
"time": time,
|
|
604
604
|
"quote": import_koishi2.h.quote(session.messageId),
|
|
605
|
-
"success":
|
|
605
|
+
"success": ".forbidden"
|
|
606
606
|
};
|
|
607
607
|
log.info("Sent:");
|
|
608
608
|
log.info(msg);
|
|
609
|
-
|
|
609
|
+
await session.send(session.text(msg["success"], msg));
|
|
610
|
+
return 0;
|
|
610
611
|
}
|
|
611
|
-
const response = await getHttp(log, api, ctx.config.timeout);
|
|
612
|
+
const response = count ? await getHttp(log, api + `&type=1&count=${count}`, ctx.config.timeout) : await getHttp(log, api, ctx.config.timeout);
|
|
612
613
|
if (response.success) {
|
|
613
614
|
data = response.data;
|
|
614
615
|
msg = {
|
|
@@ -616,7 +617,7 @@ async function getMeme(ctx, session) {
|
|
|
616
617
|
"title": data["data"]["title"],
|
|
617
618
|
"image": import_koishi2.h.image(data["data"]["image"]),
|
|
618
619
|
"quote": import_koishi2.h.quote(session.messageId),
|
|
619
|
-
"success":
|
|
620
|
+
"success": ".msg"
|
|
620
621
|
};
|
|
621
622
|
log.info("Sent:");
|
|
622
623
|
log.info(msg);
|
|
@@ -627,7 +628,7 @@ async function getMeme(ctx, session) {
|
|
|
627
628
|
"time": time,
|
|
628
629
|
"data": data["name"] === "AbortError" ? session.text(".error") : data["message"],
|
|
629
630
|
"quote": import_koishi2.h.quote(session.messageId),
|
|
630
|
-
"success":
|
|
631
|
+
"success": ".failed"
|
|
631
632
|
};
|
|
632
633
|
log.info("Sent:");
|
|
633
634
|
log.info(msg);
|
|
@@ -637,18 +638,19 @@ async function getMeme(ctx, session) {
|
|
|
637
638
|
"time": time,
|
|
638
639
|
"data": data["data"],
|
|
639
640
|
"quote": import_koishi2.h.quote(session.messageId),
|
|
640
|
-
"success":
|
|
641
|
+
"success": ".failed"
|
|
641
642
|
};
|
|
642
643
|
log.info("Sent:");
|
|
643
644
|
log.info(msg);
|
|
644
645
|
}
|
|
645
646
|
}
|
|
646
|
-
|
|
647
|
+
await session.send(session.text(msg["success"], msg));
|
|
648
|
+
return 0;
|
|
647
649
|
}
|
|
648
650
|
__name(getMeme, "getMeme");
|
|
649
651
|
|
|
650
652
|
// package.json
|
|
651
|
-
var version = "2.
|
|
653
|
+
var version = "2.16.0";
|
|
652
654
|
|
|
653
655
|
// src/index.ts
|
|
654
656
|
var inject = ["database", "installer"];
|
|
@@ -761,14 +763,11 @@ function apply(ctx) {
|
|
|
761
763
|
return session?.text(".failed", steam);
|
|
762
764
|
}
|
|
763
765
|
});
|
|
764
|
-
ctx.command("meme").alias("memes").action(async ({ session }) => {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
return session?.text(".failed", meme);
|
|
770
|
-
} else {
|
|
771
|
-
return session?.text(".forbidden", meme);
|
|
766
|
+
ctx.command("meme [序号:posint]").alias("memes").action(async ({ session }, count) => {
|
|
767
|
+
try {
|
|
768
|
+
await getMeme(ctx, session, count);
|
|
769
|
+
} catch (e) {
|
|
770
|
+
await session?.send(session?.text(".e"));
|
|
772
771
|
}
|
|
773
772
|
});
|
|
774
773
|
}
|