@azimiao/koishi-plugin-cafe-bot-exp 0.0.43 → 0.0.46

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 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";
43
+ var version = "0.0.46";
44
44
 
45
45
  // src/index.ts
46
46
  var import_censor = require("@koishijs/censor");
@@ -527,7 +527,7 @@ var CafeBotQuizConfig = import_koishi3.Schema.object({
527
527
  appendMDBtn: import_koishi3.Schema.boolean().description("是否追加QQ按钮").default(false),
528
528
  imgWidth: import_koishi3.Schema.number().description("QQ图像宽度").default(0),
529
529
  imgHeight: import_koishi3.Schema.number().description("QQ图像高度").default(0),
530
- disableDriectMD: import_koishi3.Schema.boolean().description("j禁用私聊 MD 回复").default(true),
530
+ disableDriectMD: import_koishi3.Schema.boolean().description("禁用私聊 MD 回复").default(true),
531
531
  disableDirectMDReply: import_koishi3.Schema.string().default("暂不支持私聊回复哦,请从群聊@我吧"),
532
532
  disableMDAt: import_koishi3.Schema.boolean().description("在md回复中禁用@").default(false),
533
533
  useReDefine: import_koishi3.Schema.boolean().description("test").default(false),
@@ -657,7 +657,7 @@ async function apply2(ctx, config) {
657
657
  }, { primary: "id", autoInc: true });
658
658
  await downloadQuitDataIfNotExist(ctx, config, config.forceUpdateWhenLoad);
659
659
  ctx.command("轨迹问答", "证明自己是合格的桂皮吧~");
660
- ctx.command("轨迹问答/新版出题", "测试新版出题功能", { hidden: true }).action(async (argv, _) => {
660
+ ctx.command("轨迹问答/新版出题", "新版出题", { hidden: true }).action(async (argv, _) => {
661
661
  await downloadQuitDataIfNotExist(ctx, config, false);
662
662
  var lastQuestion = await ctx.cache.get("question", argv.session.userId);
663
663
  if (lastQuestion) {
@@ -704,7 +704,7 @@ async function apply2(ctx, config) {
704
704
  {
705
705
  key: "user",
706
706
  values: [
707
- config.disableMDAt || argv.session.isDirect ? "你" : config.useReDefine ? `${config.insertBeforeAt}<qqbot-at-user id="${argv.session.userId}" />` : `${config.insertBeforeAt}<qqbot-at-user id="${argv.session.userId}" />`
707
+ config.disableMDAt || argv.session.isDirect ? "你" : config.useReDefine ? `${config.insertBeforeAt}<@${argv.session.userId}>` : `${config.insertBeforeAt}<qqbot-at-user id="${argv.session.userId}" />`
708
708
  ]
709
709
  // 群聊@,私聊不@
710
710
  },
@@ -756,7 +756,7 @@ async function apply2(ctx, config) {
756
756
  }
757
757
  if (argv.session.qq) {
758
758
  try {
759
- if (argv.session.event.guild?.id) {
759
+ if (argv.session.isDirect) {
760
760
  logger2?.info(`public msg,use sendMessage,guild id:${argv.session.event.guild.id},channelId:${argv.session.channelId}`);
761
761
  await argv.session.qq.sendMessage(argv.session.channelId, msgQQ);
762
762
  } else if (argv.session.event.user?.id) {
@@ -783,6 +783,160 @@ async function apply2(ctx, config) {
783
783
  }
784
784
  return;
785
785
  });
786
+ ctx.command("轨迹问答/新版出题测试", "测试新版出题功能", { hidden: true }).action(async (argv, _) => {
787
+ var msgQQ = {
788
+ content: "111",
789
+ msg_type: 2,
790
+ msg_id: argv.session.messageId,
791
+ timestamp: argv.session.timestamp,
792
+ markdown: {
793
+ custom_template_id: `${config.qqQuizMDTextID}`,
794
+ params: [
795
+ {
796
+ key: "user",
797
+ values: [
798
+ config.disableMDAt || argv.session.isDirect ? "你" : config.useReDefine ? `${config.insertBeforeAt}<@${argv.session.userId}>` : `${config.insertBeforeAt}<qqbot-at-user id="${argv.session.userId}" />`
799
+ ]
800
+ // 群聊@,私聊不@
801
+ },
802
+ {
803
+ key: "question",
804
+ values: ["测试问题测试问题测试问题"]
805
+ },
806
+ {
807
+ key: "max_time",
808
+ values: [`${config.answerTimeout}`]
809
+ },
810
+ {
811
+ key: "answer_a",
812
+ values: ["选项1"]
813
+ },
814
+ {
815
+ key: "answer_b",
816
+ values: ["选项2"]
817
+ },
818
+ {
819
+ key: "answer_c",
820
+ values: ["选项3"]
821
+ },
822
+ {
823
+ key: "answer_d",
824
+ values: ["选项4"]
825
+ }
826
+ ]
827
+ }
828
+ };
829
+ if (config.appendMDBtn) {
830
+ msgQQ.keyboard = {
831
+ id: config.qqQuizButtonID
832
+ };
833
+ }
834
+ if (argv.session.qq) {
835
+ try {
836
+ if (argv.session.isDirect) {
837
+ logger2?.info(`public msg,use sendMessage,guild id:${argv.session.event.guild.id},channelId:${argv.session.channelId}`);
838
+ await argv.session.qq.sendMessage(argv.session.channelId, msgQQ);
839
+ } else if (argv.session.event.user?.id) {
840
+ if (config.disableDriectMD) {
841
+ await argv.session?.send(`${At(argv)}${config.disableDirectMDReply}`);
842
+ return;
843
+ }
844
+ logger2?.info(`private msg,use sendPrivateMessage,userId:${argv.session.event.user.id}`);
845
+ await argv.session.qq.sendPrivateMessage(argv.session.event.user.id, msgQQ);
846
+ }
847
+ } catch (error) {
848
+ logger2?.error("发送QQ MD 消息失败:" + error);
849
+ logger2?.error(JSON.stringify(msgQQ));
850
+ await argv.session?.send(`${At(argv)}超级计算机『卡佩尔』发生核心故障😵(~~~)`);
851
+ }
852
+ } else {
853
+ await argv.session?.send(JSON.stringify(msgQQ));
854
+ }
855
+ return;
856
+ });
857
+ ctx.command("轨迹问答/新版出题图测试", { hidden: true }).action(async (argv, _) => {
858
+ var msgQQ = {
859
+ content: "111",
860
+ msg_type: 2,
861
+ msg_id: argv.session.messageId,
862
+ timestamp: argv.session.timestamp,
863
+ markdown: {
864
+ custom_template_id: `${config.qqQuizMDImgID}`,
865
+ params: [
866
+ {
867
+ key: "user",
868
+ values: [
869
+ config.disableMDAt || argv.session.isDirect ? "你" : config.useReDefine ? `${config.insertBeforeAt}<@${argv.session.userId}>` : `${config.insertBeforeAt}<qqbot-at-user id="${argv.session.userId}" />`
870
+ ]
871
+ // 群聊@,私聊不@
872
+ },
873
+ {
874
+ key: "question",
875
+ values: ["测试问题测试问题测试问题"]
876
+ },
877
+ {
878
+ key: "max_time",
879
+ values: [`${config.answerTimeout}`]
880
+ },
881
+ {
882
+ key: "answer_a",
883
+ values: ["选项1"]
884
+ },
885
+ {
886
+ key: "answer_b",
887
+ values: ["选项2"]
888
+ },
889
+ {
890
+ key: "answer_c",
891
+ values: ["选项3"]
892
+ },
893
+ {
894
+ key: "answer_d",
895
+ values: ["选项4"]
896
+ }
897
+ ]
898
+ }
899
+ };
900
+ msgQQ.markdown.params.push({
901
+ key: "img_url",
902
+ values: [`https://cdn.trails-game.com/wp-content/uploads/2021/07/avon.jpg`]
903
+ });
904
+ msgQQ.markdown.params.push({
905
+ key: "img_width",
906
+ values: [config.imgWidth]
907
+ });
908
+ msgQQ.markdown.params.push({
909
+ key: "img_height",
910
+ values: [config.imgHeight]
911
+ });
912
+ if (config.appendMDBtn) {
913
+ msgQQ.keyboard = {
914
+ id: config.qqQuizButtonID
915
+ };
916
+ }
917
+ if (argv.session.qq) {
918
+ try {
919
+ if (argv.session.isDirect) {
920
+ logger2?.info(`public msg,use sendMessage,guild id:${argv.session.event.guild.id},channelId:${argv.session.channelId}`);
921
+ await argv.session.qq.sendMessage(argv.session.channelId, msgQQ);
922
+ } else if (argv.session.event.user?.id) {
923
+ if (config.disableDriectMD) {
924
+ await argv.session?.send(`${At(argv)}${config.disableDirectMDReply}`);
925
+ return;
926
+ }
927
+ logger2?.info(`private msg,use sendPrivateMessage,userId:${argv.session.event.user.id}`);
928
+ await argv.session.qq.sendPrivateMessage(argv.session.event.user.id, msgQQ);
929
+ }
930
+ } catch (error) {
931
+ logger2?.error("发送QQ MD 消息失败:" + error);
932
+ logger2?.error(JSON.stringify(msgQQ));
933
+ await argv.session?.send(`${At(argv)}超级计算机『卡佩尔』发生核心故障😵(~~~)`);
934
+ }
935
+ } else {
936
+ await argv.session?.send(JSON.stringify(msgQQ));
937
+ }
938
+ return;
939
+ });
786
940
  ctx.command("轨迹问答/出题", "随机抽一道题目").action(async (argv, _) => {
787
941
  await downloadQuitDataIfNotExist(ctx, config, false);
788
942
  var lastQuestion = await ctx.cache.get("question", argv.session.userId);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@azimiao/koishi-plugin-cafe-bot-exp",
3
3
  "description": "cafe bot experiment",
4
- "version": "0.0.43",
4
+ "version": "0.0.46",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "repository": {
@@ -1,24 +0,0 @@
1
- /**
2
- * 轨迹答题配置
3
- */
4
- import { Schema } from "koishi";
5
- export interface CafeBotQuizConfig {
6
- baseQuizUrl: string;
7
- forceUpdateWhenLoad: boolean;
8
- answerTimeout: number;
9
- maxQuizPerDay: number;
10
- redisServer: string;
11
- redisAuth: string;
12
- qqQuizMDTextID: string;
13
- qqQuizMDImgID: string;
14
- qqQuizButtonID: string;
15
- appendMDBtn: boolean;
16
- imgWidth: number;
17
- imgHeight: number;
18
- disableDriectMD: boolean;
19
- disableDirectMDReply: string;
20
- disableMDAt: boolean;
21
- useReDefine: boolean;
22
- insertBeforeAt: string;
23
- }
24
- export declare const CafeBotQuizConfig: Schema<CafeBotQuizConfig>;