@azimiao/koishi-plugin-cafe-bot-exp 0.0.30 → 0.0.33
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/index.js +36 -10
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
40
40
|
var import_url = require("url");
|
|
41
41
|
|
|
42
42
|
// package.json
|
|
43
|
-
var version = "0.0.
|
|
43
|
+
var version = "0.0.33";
|
|
44
44
|
|
|
45
45
|
// src/index.ts
|
|
46
46
|
var import_censor = require("@koishijs/censor");
|
|
@@ -100,12 +100,12 @@ var PseudoRandom = class {
|
|
|
100
100
|
"seed": this.seed
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
next = () => {
|
|
103
|
+
next = /* @__PURE__ */ __name(() => {
|
|
104
104
|
return this.randFunc();
|
|
105
|
-
};
|
|
106
|
-
nextInt = (min, max) => {
|
|
105
|
+
}, "next");
|
|
106
|
+
nextInt = /* @__PURE__ */ __name((min, max) => {
|
|
107
107
|
return Math.floor(this.next() * (max - min + 1)) + min;
|
|
108
|
-
};
|
|
108
|
+
}, "nextInt");
|
|
109
109
|
};
|
|
110
110
|
var PseudoRandom_default = PseudoRandom;
|
|
111
111
|
|
|
@@ -524,12 +524,14 @@ var CafeBotQuizConfig = import_koishi3.Schema.object({
|
|
|
524
524
|
qqQuizMDTextID: import_koishi3.Schema.string().description("QQ markdown 纯本文模板ID"),
|
|
525
525
|
qqQuizMDImgID: import_koishi3.Schema.string().description("QQ markdown 题目带图模板ID"),
|
|
526
526
|
qqQuizButtonID: import_koishi3.Schema.string().description("QQ按钮ID"),
|
|
527
|
-
appendMDBtn: import_koishi3.Schema.boolean().description("是否追加QQ按钮").default(false)
|
|
527
|
+
appendMDBtn: import_koishi3.Schema.boolean().description("是否追加QQ按钮").default(false),
|
|
528
|
+
imgWidth: import_koishi3.Schema.number().description("QQ图像宽度").default(0),
|
|
529
|
+
imgHeight: import_koishi3.Schema.number().description("QQ图像高度").default(0)
|
|
528
530
|
}).description("答题配置");
|
|
529
531
|
|
|
530
532
|
// src/common/CafeTimeTools.ts
|
|
531
533
|
var CafeTimeTools = {
|
|
532
|
-
getRemainingSecondsToBeijingMidnight: function() {
|
|
534
|
+
getRemainingSecondsToBeijingMidnight: /* @__PURE__ */ __name(function() {
|
|
533
535
|
const now = /* @__PURE__ */ new Date();
|
|
534
536
|
const utcNow = now.getTime();
|
|
535
537
|
const target = new Date(now);
|
|
@@ -540,7 +542,7 @@ var CafeTimeTools = {
|
|
|
540
542
|
const diff = target.getTime() - utcNow;
|
|
541
543
|
const seconds = Math.ceil(diff / 1e3);
|
|
542
544
|
return seconds;
|
|
543
|
-
}
|
|
545
|
+
}, "getRemainingSecondsToBeijingMidnight")
|
|
544
546
|
};
|
|
545
547
|
var CafeTimeTools_default = CafeTimeTools;
|
|
546
548
|
|
|
@@ -697,7 +699,8 @@ async function apply2(ctx, config) {
|
|
|
697
699
|
params: [
|
|
698
700
|
{
|
|
699
701
|
key: "user",
|
|
700
|
-
values: [
|
|
702
|
+
values: [argv.session && !argv.session.isDirect ? `<qqbot-at-user id="${argv.session.userId}">` : ""]
|
|
703
|
+
// 群聊@,私聊不@
|
|
701
704
|
},
|
|
702
705
|
{
|
|
703
706
|
key: "question",
|
|
@@ -726,6 +729,20 @@ async function apply2(ctx, config) {
|
|
|
726
729
|
]
|
|
727
730
|
}
|
|
728
731
|
};
|
|
732
|
+
if (qItem.question.img.length > 0) {
|
|
733
|
+
msgQQ.markdown.params.push({
|
|
734
|
+
key: "img_url",
|
|
735
|
+
values: [qItem.question.img]
|
|
736
|
+
});
|
|
737
|
+
msgQQ.markdown.params.push({
|
|
738
|
+
key: "img_width",
|
|
739
|
+
values: [config.imgWidth]
|
|
740
|
+
});
|
|
741
|
+
msgQQ.markdown.params.push({
|
|
742
|
+
key: "img_height",
|
|
743
|
+
values: [config.imgHeight]
|
|
744
|
+
});
|
|
745
|
+
}
|
|
729
746
|
if (config.appendMDBtn) {
|
|
730
747
|
msgQQ.keyboard = {
|
|
731
748
|
id: config.qqQuizButtonID
|
|
@@ -733,7 +750,16 @@ async function apply2(ctx, config) {
|
|
|
733
750
|
}
|
|
734
751
|
logger2?.debug(JSON.stringify(msgQQ));
|
|
735
752
|
if (argv.session.qq) {
|
|
736
|
-
|
|
753
|
+
try {
|
|
754
|
+
if (argv.session.isDirect) {
|
|
755
|
+
await argv.session.qq.sendPrivateMessage(argv.session.channelId, msgQQ);
|
|
756
|
+
} else {
|
|
757
|
+
await argv.session.qq.sendMessage(argv.session.channelId, msgQQ);
|
|
758
|
+
}
|
|
759
|
+
} catch (error) {
|
|
760
|
+
logger2?.error("发送QQ MD 消息失败:" + error);
|
|
761
|
+
await argv.session?.send(`${At(argv)}超级计算机『卡佩尔』发生核心故障😵`);
|
|
762
|
+
}
|
|
737
763
|
} else {
|
|
738
764
|
await argv.session?.send(JSON.stringify(msgQQ));
|
|
739
765
|
}
|