koishi-plugin-node-async-bot-all 2.15.0 → 2.17.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 +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +53 -19
- package/package.json +1 -1
package/lib/commands.d.ts
CHANGED
|
@@ -13,4 +13,5 @@ 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, count: number): Promise<
|
|
16
|
+
export declare function getMeme(ctx: Context, session: Session, count: number): Promise<Number>;
|
|
17
|
+
export declare function getCat(ctx: Context, session: Session): Promise<Number>;
|
package/lib/index.d.ts
CHANGED
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: "执行错误。" } }, randomcat: { description: "随机猫猫图。", messages: { msg: "{quote}{image}", error: "执行错误。", wait: "{quote}{time}\n请等待图片上传(可能较慢)。", failed: "{quote}{time}\n获取失败:{data}" } } } };
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -500,7 +500,7 @@ async function getBA(ctx, session) {
|
|
|
500
500
|
const log = ctx.logger("ba");
|
|
501
501
|
log.info(`Got: {"form":"${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
502
502
|
const time = getHongKongTime();
|
|
503
|
-
if (ctx.config.
|
|
503
|
+
if (ctx.config.baAPI == void 0) {
|
|
504
504
|
await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": "未指定 API" }));
|
|
505
505
|
return 1;
|
|
506
506
|
}
|
|
@@ -602,11 +602,12 @@ async function getMeme(ctx, session, count) {
|
|
|
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
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) {
|
|
@@ -616,7 +617,7 @@ async function getMeme(ctx, session, count) {
|
|
|
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, count) {
|
|
|
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,52 @@ async function getMeme(ctx, session, count) {
|
|
|
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");
|
|
651
|
+
async function getCat(ctx, session) {
|
|
652
|
+
const log = ctx.logger("cat");
|
|
653
|
+
log.info(`Got: {"form":"${session.event.guild?.id}","user":"${session.event.user?.id}","timestamp":${session.event.timestamp},"messageId":"${session.event.message?.id}"}`);
|
|
654
|
+
const time = getHongKongTime();
|
|
655
|
+
if (ctx.config.catAPI == void 0) {
|
|
656
|
+
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": "未指定 API", "time": time }));
|
|
657
|
+
return 1;
|
|
658
|
+
}
|
|
659
|
+
const vid = await session.send(session.text(".wait", { "quote": import_koishi2.h.quote(session.messageId), "time": time }));
|
|
660
|
+
const response = await getHttp(log, ctx.config.catAPI, ctx.config.timeout);
|
|
661
|
+
if (response.success) {
|
|
662
|
+
const data = response.data;
|
|
663
|
+
log.info(data[0]["url"]);
|
|
664
|
+
await session.send(session.text(".msg", { "quote": import_koishi2.h.quote(session.messageId), "image": import_koishi2.h.image(data[0]["url"]) }));
|
|
665
|
+
log.info("Sent:");
|
|
666
|
+
log.info(data[0]["url"]);
|
|
667
|
+
} else {
|
|
668
|
+
if (response.error) {
|
|
669
|
+
const data = response.data;
|
|
670
|
+
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": data["name"] === "AbortError" ? session.text(".error") : data["message"], "time": time }));
|
|
671
|
+
log.info("Sent:");
|
|
672
|
+
log.info(data["message"]);
|
|
673
|
+
} else {
|
|
674
|
+
const data = response.data;
|
|
675
|
+
await session.send(session.text(".failed", { "quote": import_koishi2.h.quote(session.messageId), "data": data["data"], "time": time }));
|
|
676
|
+
log.info("Sent:");
|
|
677
|
+
log.info(data["data"]);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
await session.bot.deleteMessage(session.event.guild?.id, vid[0]);
|
|
681
|
+
return 0;
|
|
682
|
+
}
|
|
683
|
+
__name(getCat, "getCat");
|
|
649
684
|
|
|
650
685
|
// package.json
|
|
651
|
-
var version = "2.
|
|
686
|
+
var version = "2.17.0";
|
|
652
687
|
|
|
653
688
|
// src/index.ts
|
|
654
689
|
var inject = ["database", "installer"];
|
|
@@ -681,7 +716,10 @@ var Config = import_koishi3.Schema.intersect([
|
|
|
681
716
|
}).description("转换 Steam ID"),
|
|
682
717
|
import_koishi3.Schema.object({
|
|
683
718
|
memesAPI: import_koishi3.Schema.dict(String).role("table").description("群友 meme API")
|
|
684
|
-
}).description("群友 meme")
|
|
719
|
+
}).description("群友 meme"),
|
|
720
|
+
import_koishi3.Schema.object({
|
|
721
|
+
catAPI: import_koishi3.Schema.string().default("https://api.thecatapi.com/v1/images/search").description("随机猫猫图 API")
|
|
722
|
+
}).description("随机猫猫图")
|
|
685
723
|
]).description("基础设置");
|
|
686
724
|
function apply(ctx) {
|
|
687
725
|
ctx.i18n.define("zh-CN", require_zh_CN());
|
|
@@ -707,7 +745,7 @@ function apply(ctx) {
|
|
|
707
745
|
return session?.text(".failed", cx);
|
|
708
746
|
}
|
|
709
747
|
});
|
|
710
|
-
ctx.command("status").action(async ({ session }) => {
|
|
748
|
+
ctx.command("status").alias("stats").alias("状态").action(async ({ session }) => {
|
|
711
749
|
const status = await getStatus(ctx, session);
|
|
712
750
|
if (status["success"] == 0) {
|
|
713
751
|
return session?.text(".msg", status);
|
|
@@ -762,14 +800,10 @@ function apply(ctx) {
|
|
|
762
800
|
}
|
|
763
801
|
});
|
|
764
802
|
ctx.command("meme [序号:posint]").alias("memes").action(async ({ session }, count) => {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
return session?.text(".failed", meme);
|
|
770
|
-
} else {
|
|
771
|
-
return session?.text(".forbidden", meme);
|
|
772
|
-
}
|
|
803
|
+
await getMeme(ctx, session, count);
|
|
804
|
+
});
|
|
805
|
+
ctx.command("randomCat").alias("随机猫猫图").alias("随机猫猫").action(async ({ session }) => {
|
|
806
|
+
await getCat(ctx, session);
|
|
773
807
|
});
|
|
774
808
|
}
|
|
775
809
|
__name(apply, "apply");
|