koishi-plugin-noah 1.0.0 → 1.0.1

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.
@@ -0,0 +1,23 @@
1
+ import { Context } from 'koishi';
2
+ export declare class UserService {
3
+ private ctx;
4
+ constructor(ctx: Context);
5
+ /**
6
+ * Update a user's default server ID
7
+ * @param uid User ID
8
+ * @param serverId Server ID
9
+ */
10
+ updateUserDefaultServer(uid: number, serverId: number): Promise<void>;
11
+ /**
12
+ * Update a user's default card ID
13
+ * @param uid User ID
14
+ * @param cardId Card ID
15
+ */
16
+ updateUserDefaultCard(uid: number, cardId: number): Promise<void>;
17
+ /**
18
+ * Update a channel's default server ID
19
+ * @param cid Channel ID
20
+ * @param serverId Server ID
21
+ */
22
+ updateChannelDefaultServer(cid: string, serverId: number): Promise<void>;
23
+ }
@@ -1,6 +1,5 @@
1
1
  import { Session } from 'koishi';
2
2
  import { CoreConfig } from '../../types/config';
3
- export * from '../config';
4
3
  export declare function hasPermission(...perms: boolean[]): boolean;
5
4
  export declare function isPluginAdmin(session: Session, config: CoreConfig): boolean;
6
5
  export declare function isGuildAdmin(session: Session): boolean;
package/lib/index.js CHANGED
@@ -45,7 +45,7 @@ __export(core_exports, {
45
45
  logger: () => logger,
46
46
  name: () => name3
47
47
  });
48
- var import_koishi4 = require("koishi");
48
+ var import_koishi3 = require("koishi");
49
49
 
50
50
  // src/core/locales/en-US.yml
51
51
  var en_US_default = { _config: { $desc: "Core Module Settings", adminUsers: "**Plugin Admin** User ID (use inspect command to get)" }, commands: { timeout: "Noah didn't wait for your reply, please try again!", noah: { help: { description: "Show Noah help information", messages: { content: "<p>Help document:</p>\n<a>https://docs.logthm.com/noah</a>" } } }, bind: { description: "Bind card", messages: { prompt: "<p>Please enter your card number:</p>", "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", duplicate: "<p>This card has already been bound (︶^︶)</p>", name: "<p>Received! Please give this card a name, no spaces allowed:</p>", invalid_name: "<p>No spaces allowed! Please try again o(一︿一+)o</p>", success: "<p>Bound successfully, your card information is as follows:</p>\n<p>[{cardName}]</p>\n<p>{cardCode}</p>" } }, "add-server": { description: "Add server" }, card: { description: "Manage cards", messages: { "invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "invalid-select": "<p>No such option!</p>", "menu-select": "<p>[Card Management]</p>\n{card_list}\n<p>0. Add new card</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-has-bound-server": "<p>[{name}]</p>\n<p>Bound server: {defaultServerName}</p>\n<p>1. Set as default card</p>\n<p>2. View or modify card number</p>\n<p>3. Delete the card</p>\n<p>4. Rename the card</p>\n<p>5. Bind the card to a specified server</p>\n<p>0. Return to card selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected card is the same as the old default card!</p>", "menu-2-prompt": "<p>Card number: {code}</p>\n<p>Please enter the new card number:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-2-error-invalid-code": "<p>The card number is incorrect, if you don't remember it, go to the arcade to check it~</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "menu-5": "{server_list}\n<p>Please enter the serial number:</p>", "menu-5-success": "<p>Set successfully!</p>", "menu-5-error-duplicate": "<p>The selected server is the same as the old default server!</p>" } }, server: { description: "Manage servers", messages: { "invalid-select": "<p>No such option!</p>", "no-auth": "<p>Only group admins can use this feature~</p>", "admin-menu-select": "<p>[Group server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", "menu-select": "<p>[Server management]</p>\n{server_list}\n<p>0. Add new server</p>\n<p>Please enter the serial number:</p>", menu: "<p>[{name}]</p>\n<p>Type: {type}</p>\n<p>1. Set as default server</p>\n<p>2. View or modify url</p>\n<p>3. Delete the server</p>\n<p>4. Rename the server</p>\n<p>0. Return to server selection</p>\n<p>Please enter the serial number:</p>", "menu-1-success": "<p>Set successfully!</p>", "menu-1-error-duplicate": "<p>The selected server is the same as the old default server!</p>", "menu-2-prompt": "<p>The server's url: {baseUrl}</p>\n<p>Please enter the new server url:</p>\n<p>Enter 0 to return</p>", "menu-2-success": "<p>Modified successfully!</p>", "menu-3-success": "<p>Deleted successfully!</p>", "menu-4-prompt": "<p>Enter a new name, no spaces allowed:</p>", "menu-4-error-invalid-name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "menu-4-success": "<p>Modified successfully!</p>", "add-type": "<p>Please select the server type:</p>\n{server_type_list}", "add-url": "<p>Please enter the server url:</p>", "add-name": "<p>Received! Please give the server a name, no spaces allowed:</p>", "add-invalid_name": "<p>No spaces allowed! Please try again o(一︿一+)o</p>", "add-success": "<p>Added successfully, the server information is as follows:</p>\n<p>[{serverName}]</p>\n<p>Type: {serverType}</p>" } } } };
@@ -421,10 +421,45 @@ var CardService = class {
421
421
  }
422
422
  };
423
423
 
424
+ // src/core/services/user-service.ts
425
+ var UserService = class {
426
+ constructor(ctx) {
427
+ this.ctx = ctx;
428
+ }
429
+ static {
430
+ __name(this, "UserService");
431
+ }
432
+ /**
433
+ * Update a user's default server ID
434
+ * @param uid User ID
435
+ * @param serverId Server ID
436
+ */
437
+ async updateUserDefaultServer(uid, serverId) {
438
+ await this.ctx.database.set("user", uid, { defaultServerId: serverId });
439
+ }
440
+ /**
441
+ * Update a user's default card ID
442
+ * @param uid User ID
443
+ * @param cardId Card ID
444
+ */
445
+ async updateUserDefaultCard(uid, cardId) {
446
+ await this.ctx.database.set("user", uid, { defaultCardId: cardId });
447
+ }
448
+ /**
449
+ * Update a channel's default server ID
450
+ * @param cid Channel ID
451
+ * @param serverId Server ID
452
+ */
453
+ async updateChannelDefaultServer(cid, serverId) {
454
+ await this.ctx.database.set("channel", cid, { defaultServerId: serverId });
455
+ }
456
+ };
457
+
424
458
  // src/core/commands/bind.ts
425
459
  function bind(ctx, config) {
426
460
  ctx.command("bind [cardCode]").alias("绑卡").userFields(["defaultCardId", "id"]).action(async ({ session }, cardCode) => {
427
461
  const cardService = new CardService(ctx);
462
+ const userService = new UserService(ctx);
428
463
  if (!cardCode) {
429
464
  await session.send(session.text(".prompt"));
430
465
  cardCode = await session.prompt();
@@ -447,8 +482,9 @@ function bind(ctx, config) {
447
482
  if (cardName.includes(" "))
448
483
  return session.text(".invalid-name");
449
484
  const res = await cardService.createCard(session.user.id, cardCode, cardName);
450
- if (session.user.defaultCardId === 0)
451
- session.user.defaultCardId = res.id;
485
+ if (session.user.defaultCardId === 0) {
486
+ await userService.updateUserDefaultCard(session.user.id, res.id);
487
+ }
452
488
  return session.text(".success", { cardName, cardCode });
453
489
  });
454
490
  }
@@ -555,11 +591,13 @@ function card(ctx, config) {
555
591
  ctx.command("card").alias("卡片管理").userFields(["defaultCardId", "defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).action(async ({ session }) => {
556
592
  const cardService = new CardService(ctx);
557
593
  const serverService = new ServerService(ctx);
594
+ const userService = new UserService(ctx);
558
595
  return await showCardSelectMenu(
559
596
  ctx,
560
597
  session,
561
598
  cardService,
562
599
  serverService,
600
+ userService,
563
601
  session.user.id,
564
602
  session.user.defaultCardId,
565
603
  session.user.defaultServerId,
@@ -569,7 +607,7 @@ function card(ctx, config) {
569
607
  });
570
608
  }
571
609
  __name(card, "card");
572
- async function showCardSelectMenu(ctx, session, cardService, serverService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId) {
610
+ async function showCardSelectMenu(ctx, session, cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId) {
573
611
  const res = await cardService.getCardsByUid(uid);
574
612
  let cardListMsg = "";
575
613
  for (let i = 0; i < res.length; i++) {
@@ -591,11 +629,11 @@ async function showCardSelectMenu(ctx, session, cardService, serverService, uid,
591
629
  if (selectNum === 0) {
592
630
  return session.execute("bind");
593
631
  } else {
594
- return showCardMenu(ctx, session, res[selectNum - 1], cardService, serverService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
632
+ return showCardMenu(ctx, session, res[selectNum - 1], cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
595
633
  }
596
634
  }
597
635
  __name(showCardSelectMenu, "showCardSelectMenu");
598
- async function showCardMenu(ctx, session, card2, cardService, serverService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId) {
636
+ async function showCardMenu(ctx, session, card2, cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId) {
599
637
  if (card2.defaultServerId != 0) {
600
638
  const server2 = await serverService.getServerById(card2.defaultServerId);
601
639
  await session.send(session.text(".menu-has-bound-server", { name: card2.name, defaultServerName: server2.name }));
@@ -610,12 +648,12 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, uid
610
648
  return await session.text(".invalid-select");
611
649
  }
612
650
  if (selectNum === 0) {
613
- return await showCardSelectMenu(ctx, session, cardService, serverService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
651
+ return await showCardSelectMenu(ctx, session, cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
614
652
  }
615
653
  if (selectNum === 1) {
616
654
  if (userDefaultCardId === card2.id)
617
655
  return session.text(".menu-1-error-duplicate");
618
- userDefaultCardId = card2.id;
656
+ await userService.updateUserDefaultCard(uid, card2.id);
619
657
  return session.text(".menu-1-success");
620
658
  }
621
659
  if (selectNum === 2) {
@@ -624,7 +662,7 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, uid
624
662
  if (!cardCode)
625
663
  return session.text("commands.timeout");
626
664
  if (cardCode === "0")
627
- return showCardMenu(ctx, session, card2, cardService, serverService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
665
+ return showCardMenu(ctx, session, card2, cardService, serverService, userService, uid, userDefaultCardId, userDefaultServerId, cid, channelDefaultServerId);
628
666
  cardCode = processInputCardCode(cardCode);
629
667
  switch (classifyCardId(cardCode)) {
630
668
  case "invalid":
@@ -641,10 +679,11 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, uid
641
679
  await cardService.removeCard(card2.id);
642
680
  if (userDefaultCardId === card2.id) {
643
681
  const res = await cardService.getCardsByUid(uid);
644
- if (res.length === 0)
645
- userDefaultCardId = 0;
646
- else
647
- userDefaultCardId = res[0].id;
682
+ if (res.length === 0) {
683
+ await userService.updateUserDefaultCard(uid, 0);
684
+ } else {
685
+ await userService.updateUserDefaultCard(uid, res[0].id);
686
+ }
648
687
  }
649
688
  return session.text(".menu-3-success");
650
689
  }
@@ -690,19 +729,7 @@ async function showCardMenu(ctx, session, card2, cardService, serverService, uid
690
729
  __name(showCardMenu, "showCardMenu");
691
730
 
692
731
  // src/core/commands/server.ts
693
- var import_koishi3 = require("koishi");
694
-
695
- // src/core/config.ts
696
732
  var import_koishi2 = require("koishi");
697
- var coreConfig = import_koishi2.Schema.object({
698
- adminUsers: import_koishi2.Schema.union([
699
- import_koishi2.Schema.array(String),
700
- import_koishi2.Schema.transform(String, (adminUsers) => [adminUsers])
701
- ])
702
- }).i18n({
703
- "en-US": en_US_default._config,
704
- "zh-CN": zh_CN_default._config
705
- });
706
733
 
707
734
  // src/core/utils/role.ts
708
735
  function hasPermission(...perms) {
@@ -735,6 +762,7 @@ var serverValues = ["asphyxia", "mao"];
735
762
  function server(ctx, config) {
736
763
  ctx.command("server").alias("服务器管理").option("channel", "-c").userFields(["defaultServerId", "id"]).channelFields(["defaultServerId", "id"]).action(async ({ session, options }) => {
737
764
  const serverService = new ServerService(ctx);
765
+ const userService = new UserService(ctx);
738
766
  if (options.channel) {
739
767
  if (!hasPermission(isGuildAdmin(session), isPluginAdmin(session, config)))
740
768
  return session.text(".no-auth");
@@ -742,6 +770,7 @@ function server(ctx, config) {
742
770
  ctx,
743
771
  session,
744
772
  serverService,
773
+ userService,
745
774
  session.user.id,
746
775
  session.user.defaultServerId,
747
776
  session.channel.id,
@@ -752,6 +781,7 @@ function server(ctx, config) {
752
781
  ctx,
753
782
  session,
754
783
  serverService,
784
+ userService,
755
785
  session.user.id,
756
786
  session.user.defaultServerId,
757
787
  session.channel.id,
@@ -760,7 +790,7 @@ function server(ctx, config) {
760
790
  });
761
791
  }
762
792
  __name(server, "server");
763
- async function showChannelServerSelectMenu(ctx, session, serverService, uid, userDefaultServerId, cid, channelDefaultServerId) {
793
+ async function showChannelServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId) {
764
794
  const res = await serverService.getServersByCid(cid);
765
795
  let serverListMsg = "";
766
796
  for (let i = 0; i < res.length; i++) {
@@ -770,7 +800,7 @@ async function showChannelServerSelectMenu(ctx, session, serverService, uid, use
770
800
  serverListMsg += `<p>${i + 1}. ${res[i].name}</p>`;
771
801
  }
772
802
  }
773
- const msg = import_koishi3.h.unescape(session.text(".menu-select", { server_list: serverListMsg })).replace("< 群聊默认服务器", "&lt; 群聊默认服务器");
803
+ const msg = import_koishi2.h.unescape(session.text(".menu-select", { server_list: serverListMsg })).replace("< 群聊默认服务器", "&lt; 群聊默认服务器");
774
804
  await session.send(msg);
775
805
  const select = await session.prompt();
776
806
  if (!select)
@@ -780,13 +810,13 @@ async function showChannelServerSelectMenu(ctx, session, serverService, uid, use
780
810
  return session.text(".invalid-select");
781
811
  }
782
812
  if (selectNum === 0) {
783
- return addServer(ctx, session, serverService, "channel", uid, userDefaultServerId, cid, channelDefaultServerId);
813
+ return addServer(ctx, session, serverService, userService, "channel", uid, userDefaultServerId, cid, channelDefaultServerId);
784
814
  } else {
785
- return showServerMenu(ctx, session, serverService, res[selectNum - 1], "channel", uid, userDefaultServerId, cid, channelDefaultServerId);
815
+ return showServerMenu(ctx, session, serverService, userService, res[selectNum - 1], "channel", uid, userDefaultServerId, cid, channelDefaultServerId);
786
816
  }
787
817
  }
788
818
  __name(showChannelServerSelectMenu, "showChannelServerSelectMenu");
789
- async function showUserServerSelectMenu(ctx, session, serverService, uid, userDefaultServerId, cid, channelDefaultServerId) {
819
+ async function showUserServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId) {
790
820
  const res = await serverService.getServersByUid(uid);
791
821
  let serverListMsg = "";
792
822
  for (let i = 0; i < res.length; i++) {
@@ -796,7 +826,7 @@ async function showUserServerSelectMenu(ctx, session, serverService, uid, userDe
796
826
  serverListMsg += `<p>${i + 1}. ${res[i].name}</p>`;
797
827
  }
798
828
  }
799
- const msg = import_koishi3.h.unescape(session.text(".menu-select", { server_list: serverListMsg })).replace("< 默认服务器", "&lt; 默认服务器");
829
+ const msg = import_koishi2.h.unescape(session.text(".menu-select", { server_list: serverListMsg })).replace("< 默认服务器", "&lt; 默认服务器");
800
830
  await session.send(msg);
801
831
  const select = await session.prompt();
802
832
  if (!select)
@@ -806,13 +836,13 @@ async function showUserServerSelectMenu(ctx, session, serverService, uid, userDe
806
836
  return session.text(".invalid-select");
807
837
  }
808
838
  if (selectNum === 0) {
809
- return addServer(ctx, session, serverService, "user", uid, userDefaultServerId, cid, channelDefaultServerId);
839
+ return addServer(ctx, session, serverService, userService, "user", uid, userDefaultServerId, cid, channelDefaultServerId);
810
840
  } else {
811
- return showServerMenu(ctx, session, serverService, res[selectNum - 1], "user", uid, userDefaultServerId, cid, channelDefaultServerId);
841
+ return showServerMenu(ctx, session, serverService, userService, res[selectNum - 1], "user", uid, userDefaultServerId, cid, channelDefaultServerId);
812
842
  }
813
843
  }
814
844
  __name(showUserServerSelectMenu, "showUserServerSelectMenu");
815
- async function showServerMenu(ctx, session, serverService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId) {
845
+ async function showServerMenu(ctx, session, serverService, userService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId) {
816
846
  await session.send(session.text(".menu", server2));
817
847
  const select = await session.prompt();
818
848
  if (!select)
@@ -823,19 +853,19 @@ async function showServerMenu(ctx, session, serverService, server2, from, uid, u
823
853
  }
824
854
  if (selectNum === 0) {
825
855
  if (from === "user")
826
- return await showUserServerSelectMenu(ctx, session, serverService, uid, userDefaultServerId, cid, channelDefaultServerId);
856
+ return await showUserServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId);
827
857
  else
828
- return await showChannelServerSelectMenu(ctx, session, serverService, uid, userDefaultServerId, cid, channelDefaultServerId);
858
+ return await showChannelServerSelectMenu(ctx, session, serverService, userService, uid, userDefaultServerId, cid, channelDefaultServerId);
829
859
  }
830
860
  if (selectNum === 1) {
831
861
  if (from === "user") {
832
862
  if (userDefaultServerId === server2.id)
833
863
  return session.text(".menu-1-error-duplicate");
834
- userDefaultServerId = server2.id;
864
+ await userService.updateUserDefaultServer(uid, server2.id);
835
865
  } else {
836
866
  if (channelDefaultServerId === server2.id)
837
867
  return session.text(".menu-1-error-duplicate");
838
- channelDefaultServerId = server2.id;
868
+ await userService.updateChannelDefaultServer(cid, server2.id);
839
869
  }
840
870
  return session.text(".menu-1-success");
841
871
  }
@@ -845,7 +875,7 @@ async function showServerMenu(ctx, session, serverService, server2, from, uid, u
845
875
  if (!url)
846
876
  return session.text("commands.timeout");
847
877
  if (url === "0")
848
- return showServerMenu(ctx, session, serverService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId);
878
+ return showServerMenu(ctx, session, serverService, userService, server2, from, uid, userDefaultServerId, cid, channelDefaultServerId);
849
879
  await serverService.updateServer(server2.id, { baseUrl: url });
850
880
  return session.text(".menu-2-success");
851
881
  }
@@ -854,18 +884,20 @@ async function showServerMenu(ctx, session, serverService, server2, from, uid, u
854
884
  if (from === "user") {
855
885
  if (userDefaultServerId === server2.id) {
856
886
  const res = await serverService.getServersByUid(uid);
857
- if (res.length === 0)
858
- userDefaultServerId = 0;
859
- else
860
- userDefaultServerId = res[0].id;
887
+ if (res.length === 0) {
888
+ await userService.updateUserDefaultServer(uid, 0);
889
+ } else {
890
+ await userService.updateUserDefaultServer(uid, res[0].id);
891
+ }
861
892
  }
862
893
  } else {
863
894
  if (channelDefaultServerId === server2.id) {
864
895
  const res = await serverService.getServersByCid(cid);
865
- if (res.length === 0)
866
- channelDefaultServerId = 0;
867
- else
868
- channelDefaultServerId = res[0].id;
896
+ if (res.length === 0) {
897
+ await userService.updateChannelDefaultServer(cid, 0);
898
+ } else {
899
+ await userService.updateChannelDefaultServer(cid, res[0].id);
900
+ }
869
901
  }
870
902
  }
871
903
  return session.text(".menu-3-success");
@@ -882,12 +914,12 @@ async function showServerMenu(ctx, session, serverService, server2, from, uid, u
882
914
  }
883
915
  }
884
916
  __name(showServerMenu, "showServerMenu");
885
- async function addServer(ctx, session, serverService, from, uid, userDefaultServerId, cid, channelDefaultServerId) {
917
+ async function addServer(ctx, session, serverService, userService, from, uid, userDefaultServerId, cid, channelDefaultServerId) {
886
918
  let serverTypeListMsg = "";
887
919
  for (let i = 0; i < serverValues.length; i++) {
888
920
  serverTypeListMsg += `<p>${i + 1}. ${serverValues[i]}</p>`;
889
921
  }
890
- const msg = import_koishi3.h.unescape(session.text(".add-type", { server_type_list: serverTypeListMsg }));
922
+ const msg = import_koishi2.h.unescape(session.text(".add-type", { server_type_list: serverTypeListMsg }));
891
923
  await session.send(msg);
892
924
  const select = await session.prompt();
893
925
  if (!select)
@@ -920,11 +952,11 @@ async function addServer(ctx, session, serverService, from, uid, userDefaultServ
920
952
  }, cid);
921
953
  if (from === "user") {
922
954
  if (userDefaultServerId === 0) {
923
- userDefaultServerId = res.id;
955
+ await userService.updateUserDefaultServer(uid, res.id);
924
956
  }
925
957
  } else {
926
958
  if (channelDefaultServerId === 0) {
927
- channelDefaultServerId = res.id;
959
+ await userService.updateChannelDefaultServer(cid, res.id);
928
960
  }
929
961
  }
930
962
  return session.text(".add-success", { serverName, serverType });
@@ -944,7 +976,7 @@ __name(apply2, "apply");
944
976
  // src/core/index.ts
945
977
  var name3 = "Noah-Core";
946
978
  var inject = ["database"];
947
- var logger = new import_koishi4.Logger("Noah-Core");
979
+ var logger = new import_koishi3.Logger("Noah-Core");
948
980
  function apply3(ctx, config) {
949
981
  [["en-US", en_US_default], ["zh-CN", zh_CN_default]].forEach(([lang, file]) => ctx.i18n.define(lang, file));
950
982
  ctx.plugin(database_exports, config.core);
@@ -960,7 +992,7 @@ __export(sdvx_exports, {
960
992
  logger: () => logger2,
961
993
  name: () => name9
962
994
  });
963
- var import_koishi9 = require("koishi");
995
+ var import_koishi8 = require("koishi");
964
996
 
965
997
  // src/games/sdvx/locales/en-US.yml
966
998
  var en_US_default2 = { _config: { $desc: "SDVX Module Settings", default_model: "<p>Default model value (e.g. `2024110700`)</p>" }, commands: { vf: { description: "Show Noah help information", messages: { "card-not-found": "<p>You haven't bound a card yet, go bind a card first~</p>", "server-not-found": "<p>No available servers, add one yourself~</p>", "no-scores-found": "<p>No scores found, please check your data.</p>", error: "<p>An error occurred:</p>\n<p>{message}</p>", drawing: "<p>Noah is drawing, please wait patiently~</p>" } } } };
@@ -987,7 +1019,7 @@ __export(command_exports2, {
987
1019
  });
988
1020
 
989
1021
  // src/games/sdvx/commands/vf.ts
990
- var import_koishi8 = require("koishi");
1022
+ var import_koishi7 = require("koishi");
991
1023
 
992
1024
  // src/servers/index.ts
993
1025
  var servers_exports = {};
@@ -998,7 +1030,7 @@ __export(servers_exports, {
998
1030
  });
999
1031
 
1000
1032
  // src/servers/Asphyxia/index.ts
1001
- var import_koishi5 = require("koishi");
1033
+ var import_koishi4 = require("koishi");
1002
1034
 
1003
1035
  // src/servers/utils/xml.ts
1004
1036
  var xml2js = __toESM(require("xml2js"));
@@ -1133,7 +1165,7 @@ var Asphyxia = class {
1133
1165
  name = "asphyxia";
1134
1166
  supportedGames = ["sdvx", "iidx"];
1135
1167
  gameServices = {};
1136
- logger = new import_koishi5.Logger("Noah-Asphyxia");
1168
+ logger = new import_koishi4.Logger("Noah-Asphyxia");
1137
1169
  constructor() {
1138
1170
  this.gameServices["sdvx"] = SDVXService.getInstance(this.logger);
1139
1171
  this.gameServices["iidx"] = IIDXService.getInstance(this.logger);
@@ -1141,7 +1173,7 @@ var Asphyxia = class {
1141
1173
  };
1142
1174
 
1143
1175
  // src/servers/Mao/index.ts
1144
- var import_koishi6 = require("koishi");
1176
+ var import_koishi5 = require("koishi");
1145
1177
 
1146
1178
  // src/servers/utils/grade.ts
1147
1179
  function getSDVXGrade(score) {
@@ -1551,7 +1583,7 @@ var Mao = class {
1551
1583
  name = "mao";
1552
1584
  supportedGames = ["sdvx"];
1553
1585
  gameServices = {};
1554
- logger = new import_koishi6.Logger("Noah-Mao");
1586
+ logger = new import_koishi5.Logger("Noah-Mao");
1555
1587
  constructor() {
1556
1588
  this.gameServices["sdvx"] = SDVXService2.getInstance(this.logger);
1557
1589
  }
@@ -1655,7 +1687,7 @@ __export(drawer_exports, {
1655
1687
  apply: () => apply6,
1656
1688
  name: () => name6
1657
1689
  });
1658
- var import_koishi7 = require("koishi");
1690
+ var import_koishi6 = require("koishi");
1659
1691
 
1660
1692
  // src/drawer/BaseDrawer.ts
1661
1693
  var import_sharp = __toESM(require("sharp"));
@@ -2242,7 +2274,7 @@ var DrawerManager = class _DrawerManager {
2242
2274
  logger;
2243
2275
  constructor(ctx) {
2244
2276
  this.factory = new DrawerFactory(ctx);
2245
- this.logger = new import_koishi7.Logger("Noah-Drawer");
2277
+ this.logger = new import_koishi6.Logger("Noah-Drawer");
2246
2278
  }
2247
2279
  static getInstance(ctx) {
2248
2280
  if (!_DrawerManager.instance) {
@@ -2306,9 +2338,9 @@ function vf(ctx, config) {
2306
2338
  lossless: options.lossless || false
2307
2339
  });
2308
2340
  if (options.lossless) {
2309
- return import_koishi8.h.file(imageBuffer, "image/png");
2341
+ return import_koishi7.h.file(imageBuffer, "image/png");
2310
2342
  }
2311
- return import_koishi8.h.image(imageBuffer, "image/jpg");
2343
+ return import_koishi7.h.image(imageBuffer, "image/jpg");
2312
2344
  } catch (error) {
2313
2345
  ctx.logger("SDVX-VF").warn(error);
2314
2346
  return session.text(".error", { message: error.message });
@@ -2338,7 +2370,7 @@ __name(apply8, "apply");
2338
2370
  // src/games/sdvx/index.ts
2339
2371
  var name9 = "Noah-SDVX";
2340
2372
  var inject2 = ["database"];
2341
- var logger2 = new import_koishi9.Logger("Noah-SDVX");
2373
+ var logger2 = new import_koishi8.Logger("Noah-SDVX");
2342
2374
  async function apply9(ctx, config) {
2343
2375
  [["en-US", en_US_default2], ["zh-CN", zh_CN_default2]].forEach(([lang, file]) => ctx.i18n.define(lang, file));
2344
2376
  ctx.plugin(database_exports2, config.sdvx);
@@ -2354,6 +2386,18 @@ __name(apply9, "apply");
2354
2386
  // src/config.ts
2355
2387
  var import_koishi11 = require("koishi");
2356
2388
 
2389
+ // src/core/config.ts
2390
+ var import_koishi9 = require("koishi");
2391
+ var coreConfig = import_koishi9.Schema.object({
2392
+ adminUsers: import_koishi9.Schema.union([
2393
+ import_koishi9.Schema.array(String),
2394
+ import_koishi9.Schema.transform(String, (adminUsers) => [adminUsers])
2395
+ ])
2396
+ }).i18n({
2397
+ "en-US": en_US_default._config,
2398
+ "zh-CN": zh_CN_default._config
2399
+ });
2400
+
2357
2401
  // src/games/sdvx/config.ts
2358
2402
  var import_koishi10 = require("koishi");
2359
2403
  var sdvxConfig = import_koishi10.Schema.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-noah",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "contributors": [
5
5
  "Logthm <logthm@outlook.com>"
6
6
  ],