karin-plugin-mys-core 1.0.0 → 1.0.2

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.
Files changed (168) hide show
  1. package/LICENSE +674 -0
  2. package/lib/apps/MiHoYoLogin.d.ts +3 -1
  3. package/lib/apps/MiHoYoLogin.js +181 -125
  4. package/lib/apps/MysDevice.d.ts +5 -0
  5. package/lib/apps/MysDevice.js +101 -0
  6. package/lib/apps/UIDManage.d.ts +10 -0
  7. package/lib/apps/UIDManage.js +52 -0
  8. package/lib/array-CZDr9qst.d.ts +62 -0
  9. package/lib/chunk-2DHTKQ34.js +0 -0
  10. package/lib/chunk-3BIQN6QA.js +27 -0
  11. package/lib/chunk-3CNBOOKY.js +31 -0
  12. package/lib/chunk-5NA7ZPDS.js +54 -0
  13. package/lib/chunk-6PIXUPZ6.js +82 -0
  14. package/lib/chunk-7KEG6SDX.js +0 -0
  15. package/lib/chunk-7SZX3RBZ.js +0 -0
  16. package/lib/chunk-7VAWV6ZE.js +0 -0
  17. package/lib/chunk-7WESXE4X.js +29 -0
  18. package/lib/chunk-7YZHHLS5.js +130 -0
  19. package/lib/chunk-ARLTXJFJ.js +0 -0
  20. package/lib/chunk-CFS2WFOO.js +0 -0
  21. package/lib/chunk-EMAUATE3.js +217 -0
  22. package/lib/chunk-FBWSEBAW.js +0 -0
  23. package/lib/chunk-FOAQZIZ2.js +0 -0
  24. package/lib/chunk-G547WVGV.js +73 -0
  25. package/lib/chunk-G5W5WAY5.js +64 -0
  26. package/lib/chunk-HVYNK5BN.js +45 -0
  27. package/lib/chunk-I7XZONDN.js +13 -0
  28. package/lib/chunk-IVZICDGW.js +19 -0
  29. package/lib/chunk-JBGXPVO2.js +179 -0
  30. package/lib/chunk-JRH4JC43.js +0 -0
  31. package/lib/chunk-JVJQKRJ4.js +89 -0
  32. package/lib/chunk-K5U2O3HH.js +0 -0
  33. package/lib/chunk-KN5SHBVI.js +30 -0
  34. package/lib/chunk-LG34FPBI.js +50 -0
  35. package/lib/chunk-LJSDSOY6.js +0 -0
  36. package/lib/chunk-LYTNREAI.js +0 -0
  37. package/lib/chunk-MWYDWDR4.js +0 -0
  38. package/lib/chunk-QMSYS77M.js +38 -0
  39. package/lib/chunk-SEWEEPJN.js +0 -0
  40. package/lib/{chunk-JML6VYXN.js → chunk-SHLPPEAY.js} +13 -17
  41. package/lib/chunk-SHW6FHIB.js +10 -0
  42. package/lib/chunk-W4DBT7AD.js +0 -0
  43. package/lib/chunk-X75DW4KI.js +510 -0
  44. package/lib/chunk-XQWTJIT4.js +0 -0
  45. package/lib/chunk-Y3J3J5B2.js +124 -0
  46. package/lib/chunk-Z5I6A73Y.js +0 -0
  47. package/lib/common-Dw5l6Uud.d.ts +33 -0
  48. package/lib/define-BWuQ7acM.d.ts +131 -0
  49. package/lib/dir.d.ts +11 -13
  50. package/lib/dir.js +1 -1
  51. package/lib/exports/config/array.d.ts +1 -0
  52. package/lib/exports/config/array.js +7 -0
  53. package/lib/exports/config/config.d.ts +1 -0
  54. package/lib/exports/config/config.js +8 -0
  55. package/lib/exports/config/index.d.ts +2 -0
  56. package/lib/exports/config/index.js +14 -0
  57. package/lib/exports/config/types/config.d.ts +12 -0
  58. package/lib/exports/config/types/config.js +1 -0
  59. package/lib/exports/config/types/index.d.ts +1 -0
  60. package/lib/exports/config/types/index.js +2 -0
  61. package/lib/exports/database/database.d.ts +30 -0
  62. package/lib/exports/database/database.js +18 -0
  63. package/lib/exports/database/dbs/base.d.ts +23 -0
  64. package/lib/exports/database/dbs/base.js +15 -0
  65. package/lib/exports/database/dbs/index.d.ts +4 -0
  66. package/lib/exports/database/dbs/index.js +23 -0
  67. package/lib/exports/database/dbs/sqlite3.d.ts +23 -0
  68. package/lib/exports/database/dbs/sqlite3.js +19 -0
  69. package/lib/exports/database/dbs/table.d.ts +13 -0
  70. package/lib/exports/database/dbs/table.js +19 -0
  71. package/lib/exports/database/index.d.ts +12 -0
  72. package/lib/exports/database/index.js +62 -0
  73. package/lib/exports/database/tables/index.d.ts +9 -0
  74. package/lib/exports/database/tables/index.js +39 -0
  75. package/lib/exports/database/tables/mysAccountInfo.d.ts +9 -0
  76. package/lib/exports/database/tables/mysAccountInfo.js +23 -0
  77. package/lib/exports/database/tables/mysDeviceInfo.d.ts +9 -0
  78. package/lib/exports/database/tables/mysDeviceInfo.js +26 -0
  79. package/lib/exports/database/tables/mysUserInfo.d.ts +9 -0
  80. package/lib/exports/database/tables/mysUserInfo.js +23 -0
  81. package/lib/exports/database/types/database.d.ts +6 -0
  82. package/lib/exports/database/types/database.js +1 -0
  83. package/lib/exports/database/types/dbs/base.d.ts +114 -0
  84. package/lib/exports/database/types/dbs/base.js +11 -0
  85. package/lib/exports/database/types/dbs/index.d.ts +2 -0
  86. package/lib/exports/database/types/dbs/index.js +12 -0
  87. package/lib/exports/database/types/index.d.ts +6 -0
  88. package/lib/exports/database/types/index.js +24 -0
  89. package/lib/exports/database/types/tables/index.d.ts +5 -0
  90. package/lib/exports/database/types/tables/index.js +13 -0
  91. package/lib/exports/database/types/tables/mysAccountInfo.d.ts +14 -0
  92. package/lib/exports/database/types/tables/mysAccountInfo.js +7 -0
  93. package/lib/exports/database/types/tables/mysDeviceInfo.d.ts +19 -0
  94. package/lib/exports/database/types/tables/mysDeviceInfo.js +1 -0
  95. package/lib/exports/database/types/tables/mysUserInfo.d.ts +31 -0
  96. package/lib/exports/database/types/tables/mysUserInfo.js +7 -0
  97. package/lib/exports/mys/api/apis.d.ts +82 -0
  98. package/lib/exports/mys/api/apis.js +57 -0
  99. package/lib/exports/mys/api/app.d.ts +60 -0
  100. package/lib/exports/mys/api/app.js +31 -0
  101. package/lib/exports/mys/api/define.d.ts +6 -0
  102. package/lib/exports/mys/api/define.js +43 -0
  103. package/lib/exports/mys/api/index.d.ts +11 -0
  104. package/lib/exports/mys/api/index.js +64 -0
  105. package/lib/exports/mys/index.d.ts +13 -0
  106. package/lib/exports/mys/index.js +77 -0
  107. package/lib/exports/mys/types/api/define.d.ts +6 -0
  108. package/lib/exports/mys/types/api/define.js +1 -0
  109. package/lib/exports/mys/types/api/index.d.ts +6 -0
  110. package/lib/exports/mys/types/api/index.js +2 -0
  111. package/lib/exports/mys/types/index.d.ts +10 -0
  112. package/lib/exports/mys/types/index.js +12 -0
  113. package/lib/exports/mys/types/user/game.d.ts +10 -0
  114. package/lib/exports/mys/types/user/game.js +1 -0
  115. package/lib/exports/mys/types/user/index.d.ts +10 -0
  116. package/lib/exports/mys/types/user/index.js +9 -0
  117. package/lib/exports/mys/types/user/userInfo.d.ts +10 -0
  118. package/lib/exports/mys/types/user/userInfo.js +7 -0
  119. package/lib/exports/mys/user/deviceInfo.d.ts +11 -0
  120. package/lib/exports/mys/user/deviceInfo.js +29 -0
  121. package/lib/exports/mys/user/game.d.ts +20 -0
  122. package/lib/exports/mys/user/game.js +7 -0
  123. package/lib/exports/mys/user/index.d.ts +12 -0
  124. package/lib/exports/mys/user/index.js +51 -0
  125. package/lib/exports/mys/user/userInfo.d.ts +10 -0
  126. package/lib/exports/mys/user/userInfo.js +45 -0
  127. package/lib/exports/utils/common.d.ts +1 -0
  128. package/lib/exports/utils/common.js +13 -0
  129. package/lib/exports/utils/index.d.ts +2 -0
  130. package/lib/exports/utils/index.js +12 -0
  131. package/lib/exports/utils/render.d.ts +21 -0
  132. package/lib/exports/utils/render.js +7 -0
  133. package/lib/index-DEEWbZ0V.d.ts +102 -0
  134. package/lib/index.js +1 -1
  135. package/package.json +29 -16
  136. package/resources/fonts/HYWenHei-55W.ttf +0 -0
  137. package/resources/image/launcher-icon//345/216/237/347/245/236.png +0 -0
  138. package/resources/image/launcher-icon//345/264/251/345/235/2173.png +0 -0
  139. package/resources/image/launcher-icon//345/264/251/345/235/217/345/255/246/345/233/2552.png +0 -0
  140. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/345/233/240/347/274/230/347/262/276/347/201/265.png +0 -0
  141. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/346/230/237/347/251/271/351/223/201/351/201/223.png +0 -0
  142. package/resources/image/launcher-icon//346/230/237/345/270/203/350/260/267/345/234/260.png +0 -0
  143. package/resources/image/launcher-icon//346/234/252/345/256/232/344/272/213/344/273/266/347/260/277.png +0 -0
  144. package/resources/image/launcher-icon//347/273/235/345/214/272/351/233/266.png +0 -0
  145. package/resources/image/mys-logo.png +0 -0
  146. package/resources/template/ShowBindAccount/index.css +1 -0
  147. package/resources/template/ShowBindAccount/index.html +65 -0
  148. package/resources/template/ShowBindDevice/index.html +20 -0
  149. package/resources/template/ShowBindDevice/inex.css +1 -0
  150. package/resources/template/layout/default.css +1 -0
  151. package/resources/template/layout/default.html +27 -0
  152. package/config/config.json +0 -3
  153. package/lib/app.d.ts +0 -2
  154. package/lib/base-B1BvQ4ol.d.ts +0 -99
  155. package/lib/chunk-4JTLXC2G.js +0 -519
  156. package/lib/chunk-7QISGXVH.js +0 -347
  157. package/lib/chunk-JIO4GOQA.js +0 -31
  158. package/lib/database-BDHrI6Vm.d.ts +0 -5
  159. package/lib/define-CrfHwHnK.d.ts +0 -163
  160. package/lib/exports/core.d.ts +0 -228
  161. package/lib/exports/core.js +0 -39
  162. package/lib/exports/database.d.ts +0 -47
  163. package/lib/exports/database.js +0 -17
  164. package/lib/exports/types.d.ts +0 -10
  165. package/lib/exports/types.js +0 -11
  166. package/lib/index.d.ts +0 -2
  167. package/lib/web.config.d.ts +0 -5
  168. package/lib/web.config.js +0 -30
@@ -1,24 +1,60 @@
1
+ import {
2
+ ShowBindAccountCmdFunc
3
+ } from "../chunk-JBGXPVO2.js";
1
4
  import {
2
5
  UserInfo,
3
- common_exports,
4
6
  fetchQRcode,
5
7
  getCookieAccountInfoByGameToken,
6
8
  getTokenByGameToken,
7
9
  getUserFullInfo,
8
10
  queryQRcode
9
- } from "../chunk-4JTLXC2G.js";
10
- import "../chunk-7QISGXVH.js";
11
- import "../chunk-JML6VYXN.js";
12
- import "../chunk-JIO4GOQA.js";
11
+ } from "../chunk-X75DW4KI.js";
12
+ import "../chunk-3CNBOOKY.js";
13
+ import "../chunk-3BIQN6QA.js";
14
+ import "../chunk-G5W5WAY5.js";
15
+ import "../chunk-7VAWV6ZE.js";
16
+ import "../chunk-LJSDSOY6.js";
17
+ import "../chunk-CFS2WFOO.js";
18
+ import "../chunk-MWYDWDR4.js";
19
+ import "../chunk-FOAQZIZ2.js";
20
+ import "../chunk-IVZICDGW.js";
21
+ import "../chunk-XQWTJIT4.js";
22
+ import "../chunk-7SZX3RBZ.js";
23
+ import "../chunk-W4DBT7AD.js";
24
+ import "../chunk-Z5I6A73Y.js";
25
+ import "../chunk-7WESXE4X.js";
26
+ import "../chunk-KN5SHBVI.js";
27
+ import "../chunk-QMSYS77M.js";
28
+ import "../chunk-SEWEEPJN.js";
29
+ import "../chunk-5NA7ZPDS.js";
30
+ import "../chunk-G547WVGV.js";
31
+ import "../chunk-EMAUATE3.js";
32
+ import "../chunk-Y3J3J5B2.js";
33
+ import "../chunk-7KEG6SDX.js";
34
+ import "../chunk-FBWSEBAW.js";
35
+ import "../chunk-JVJQKRJ4.js";
36
+ import "../chunk-LYTNREAI.js";
37
+ import "../chunk-K5U2O3HH.js";
38
+ import "../chunk-I7XZONDN.js";
39
+ import "../chunk-SHW6FHIB.js";
40
+ import "../chunk-JRH4JC43.js";
41
+ import "../chunk-ARLTXJFJ.js";
42
+ import {
43
+ common_exports
44
+ } from "../chunk-LG34FPBI.js";
45
+ import "../chunk-HVYNK5BN.js";
46
+ import "../chunk-2DHTKQ34.js";
47
+ import "../chunk-SHLPPEAY.js";
48
+ import "../chunk-7YZHHLS5.js";
49
+ import "../chunk-6PIXUPZ6.js";
13
50
  import "../chunk-MLKGABMK.js";
14
51
 
15
52
  // src/apps/MiHoYoLogin.ts
16
53
  import karin, { common as karinCommon, logger, segment } from "node-karin";
17
- import lodash from "node-karin/lodash";
18
54
  import QR from "qrcode";
19
55
  var QRCodes = /* @__PURE__ */ new Map();
20
56
  var MiHoYoLoginQRCode = karin.command(
21
- /^#?(扫码|二维码|辅助)(登录|绑定|登陆)$/i,
57
+ /^#?(扫码|米哈游|mys)(登录|绑定)$/i,
22
58
  async (e) => {
23
59
  const qrcode = QRCodes.get(e.userId);
24
60
  if (qrcode) {
@@ -31,47 +67,49 @@ var MiHoYoLoginQRCode = karin.command(
31
67
  }
32
68
  QRCodes.set(e.userId, true);
33
69
  const device = common_exports.randomString(64, "All");
34
- const QRcode = await fetchQRcode().request({ device });
70
+ const QRcode = (await fetchQRcode.init(null).request({ device })).data;
35
71
  if (!QRcode?.data?.url) {
36
72
  QRCodes.delete(e.userId);
37
- e.reply("\u83B7\u53D6\u4E8C\u7EF4\u7801\u5931\u8D25\u3001\u8BF7\u7A0D\u540E\u518D\u8BD5", { at: true });
73
+ e.reply("\u83B7\u53D6\u4E8C\u7EF4\u7801\u5931\u8D25\u3001\u8BF7\u7A0D\u540E\u518D\u8BD5...", { at: true });
38
74
  return true;
39
75
  }
40
76
  const image = (await QR.toDataURL(QRcode.data.url)).replace("data:image/png;base64,", "base64://");
41
77
  if (!image) {
42
78
  QRCodes.delete(e.userId);
43
- e.reply("\u751F\u6210\u4E8C\u7EF4\u7801\u5931\u8D25\u3001\u8BF7\u7A0D\u540E\u518D\u8BD5", { at: true });
79
+ e.reply("\u751F\u6210\u4E8C\u7EF4\u7801\u5931\u8D25\u3001\u8BF7\u7A0D\u540E\u518D\u8BD5...", { at: true });
44
80
  return true;
45
81
  }
46
82
  QRCodes.set(e.userId, image);
47
83
  e.reply(["\u8BF7\u4F7F\u7528\u7C73\u6E38\u793E\u626B\u7801\u767B\u5F55", segment.image(image)], { at: true, recallMsg: 60 });
84
+ setTimeout(() => {
85
+ QRCodes.delete(e.userId);
86
+ }, 5 * 60 * 1e3);
48
87
  let data, Scanned;
49
88
  const ticket = QRcode.data.url.split("ticket=")[1];
50
89
  for (let n = 1; n < 60; n++) {
51
90
  await karinCommon.sleep(5e3);
52
91
  try {
53
- const res3 = await queryQRcode().request({ device, ticket });
54
- if (!res3) continue;
55
- if (res3.retcode === 3503) {
56
- e.reply(res3.message, { at: true, recallMsg: 60 });
92
+ const res = (await queryQRcode.init(null).request({ device, ticket })).data;
93
+ if (!res) continue;
94
+ if (res.retcode === 3503) {
57
95
  QRCodes.delete(e.userId);
96
+ e.reply(res.message, { at: true });
58
97
  return true;
59
98
  }
60
- if (res3.retcode !== 0) {
61
- e.reply("\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55", { at: true, recallMsg: 60 });
99
+ if (res.retcode !== 0) {
62
100
  QRCodes.delete(e.userId);
101
+ e.reply("\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55", { at: true });
63
102
  return true;
64
103
  }
65
- if (res3.data.stat === "Scanned") {
104
+ if (res.data.stat === "Scanned") {
66
105
  if (Scanned) {
67
- e.reply("\u4E8C\u7EF4\u7801\u5DF2\u626B\u63CF\uFF0C\u8BF7\u786E\u8BA4\u767B\u5F55", { at: true, recallMsg: 60 });
106
+ e.reply("\u4E8C\u7EF4\u7801\u5DF2\u626B\u63CF\uFF0C\u8BF7\u786E\u8BA4\u767B\u5F55", { at: true });
68
107
  } else {
69
108
  Scanned = true;
70
109
  QRCodes.set(e.userId, true);
71
110
  }
72
- }
73
- if (res3.data.stat === "Confirmed") {
74
- data = JSON.parse(res3.data.payload.raw);
111
+ } else if (res.data.stat === "Confirmed") {
112
+ data = JSON.parse(res.data.payload.raw);
75
113
  break;
76
114
  }
77
115
  } catch (err) {
@@ -79,41 +117,105 @@ var MiHoYoLoginQRCode = karin.command(
79
117
  break;
80
118
  }
81
119
  }
82
- if (!data?.uid && !data?.token) {
83
- e.reply("\u7C73\u6E38\u793E\u767B\u5F55\u5931\u8D25", { at: true });
120
+ if (!data?.uid || !data?.token) {
84
121
  QRCodes.delete(e.userId);
122
+ e.reply("\u7C73\u6E38\u793E\u767B\u5F55\u5931\u8D25", { at: true });
85
123
  return true;
86
124
  }
87
- const res = await getTokenByGameToken().request({
125
+ const Token = (await getTokenByGameToken.init(null).request({
88
126
  account_id: parseInt(data.uid),
89
127
  game_token: data.token
90
- });
91
- if (!res) {
92
- e.reply("\u83B7\u53D6Token\u5931\u8D25", { at: true });
128
+ })).data;
129
+ if (!Token?.data?.token?.token) {
93
130
  QRCodes.delete(e.userId);
131
+ e.reply("\u83B7\u53D6Token\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002", { at: true });
94
132
  return true;
95
133
  }
96
- const stoken = `stoken=${res.data.token.token};stuid=${res.data.user_info.aid};mid=${res.data.user_info.mid};`;
97
- const res2 = await getCookieAccountInfoByGameToken().request({
134
+ const stokenParams = {
135
+ stuid: Token.data.user_info.aid,
136
+ stoken: Token.data.token.token,
137
+ mid: Token.data.user_info.mid
138
+ };
139
+ const CookieAccountInfo = (await getCookieAccountInfoByGameToken.init(null).request({
98
140
  account_id: data.uid,
99
141
  game_token: data.token
100
- });
101
- const cookie = `ltuid=${res.data.user_info.aid};ltoken=${res.data.token.token};cookie_token=${res2.data.cookie_token};account_id=${res.data.user_info.aid}`;
102
- const message = await bingStoken(e.userId, stoken, { cookie, Serv: "mihoyo" /* cn */ });
103
- e.reply(message, { at: true });
142
+ })).data;
143
+ if (!CookieAccountInfo?.data?.cookie_token) {
144
+ QRCodes.delete(e.userId);
145
+ e.reply("\u83B7\u53D6CookieToken\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002", { at: true });
146
+ return true;
147
+ }
148
+ const cookieParams = {
149
+ ltuid: stokenParams.stuid,
150
+ ltoken: stokenParams.stoken,
151
+ cookie_token: CookieAccountInfo.data.cookie_token,
152
+ account_id: stokenParams.stuid
153
+ };
154
+ const errMsg = await BindStoken(e.userId, stokenParams, { cookieParams, Serv: "mihoyo" /* cn */ });
155
+ if (errMsg) {
156
+ e.reply(errMsg, { at: true });
157
+ return true;
158
+ }
104
159
  QRCodes.delete(e.userId);
105
- return true;
160
+ return await ShowBindAccountCmdFunc(e);
106
161
  }
107
162
  );
108
- var bingCookie = async (userId, cookie, Serv = "mihoyo" /* cn */) => {
109
- const cookieObj = common_exports.StrToObj(cookie.replace(/[#'" ]/g, ""), ";");
163
+ var BindCookieByMessage = karin.command(
164
+ /^#?绑定(米游社)?(cookie|ck)$/i,
165
+ async (e) => {
166
+ const cookieMsg = e.msg.replace(/^#?绑定(米游社)?(cookie|ck)/i, "").trim();
167
+ const cookieObj = common_exports.StrToObj(cookieMsg.replace(/[#'" ]/g, ""), ";");
168
+ const errMsg = await BindCookie(e.userId, cookieObj, 1 /* CK */);
169
+ if (errMsg) {
170
+ e.reply(errMsg, { at: true });
171
+ return true;
172
+ }
173
+ return await ShowBindAccountCmdFunc(e);
174
+ }
175
+ );
176
+ var BindStokenByMessage = karin.command(
177
+ /^#?绑定(米游社)?(stoken|sk)$/i,
178
+ async (e) => {
179
+ const stokenMsg = e.msg.replace(/^#?绑定(米游社)?(stoken|sk)$/i, "").trim();
180
+ const stokenObj = common_exports.StrToObj(stokenMsg.replace(/[#'" ]/g, ""), ";");
181
+ if (!stokenObj.stoken || !(stokenObj.stuid || stokenObj.ltuid) || !stokenObj.mid) {
182
+ e.reply("\u53D1\u9001Stoken\u4E0D\u5B8C\u6574\uFF0C\u5EFA\u8BAE\u4F7F\u7528#\u7C73\u54C8\u6E38\u767B\u5F55", { at: true });
183
+ return true;
184
+ }
185
+ const errMsg = await BindStoken(e.userId, {
186
+ stuid: stokenObj.stuid || stokenObj.ltuid,
187
+ stoken: stokenObj.stoken,
188
+ mid: stokenObj.mid
189
+ });
190
+ if (errMsg) {
191
+ e.reply(errMsg, { at: true });
192
+ return true;
193
+ }
194
+ return await ShowBindAccountCmdFunc(e);
195
+ }
196
+ );
197
+ var BindStoken = async (userId, stokenParams, option) => {
198
+ const updata = Object.keys(option?.cookieParams || {}).length > 0 ? { Serv: option.Serv, cookieParams: option.cookieParams, message: "" } : await UserInfo.refreshCookie(stokenParams, option?.Serv ?? ["mihoyo" /* cn */, "hoyolab" /* os */]);
199
+ if (updata.message) return updata.message;
200
+ const userInfo = await UserInfo.create(userId);
201
+ await userInfo.saveUserInfo({
202
+ stuids: userInfo.stuids.add(stokenParams.stuid, true)
203
+ });
204
+ await userInfo.saveMysAccountInfo(stokenParams.stuid, {
205
+ type: updata.Serv,
206
+ stoken: common_exports.ObjToStr(stokenParams, ";")
207
+ });
208
+ logger.mark(`[${userId}] \u4FDD\u5B58Stoken\u6210\u529F [stuid: ${stokenParams.stuid}]`);
209
+ const errMsg = await BindCookie(userId, updata.cookieParams, 3 /* CS */, updata.Serv);
210
+ if (errMsg) return errMsg;
211
+ return false;
212
+ };
213
+ var BindCookie = async (userId, cookieObj, perm, Serv) => {
110
214
  if (!cookieObj.cookie_token && !cookieObj.cookie_token_v2) {
111
- return "\u53D1\u9001Cookie\u4E0D\u5B8C\u6574\uFF0C\u5EFA\u8BAE\u4F7F\u7528#\u626B\u7801\u767B\u5F55";
215
+ return "\u53D1\u9001Cookie\u4E0D\u5B8C\u6574(cookie_token\u7F3A\u5931)\uFF0C\u5EFA\u8BAE\u4F7F\u7528#\u7C73\u54C8\u6E38\u767B\u5F55\u3002";
112
216
  }
113
217
  const ltuid = cookieObj.ltuid || cookieObj.login_uid || cookieObj.ltuid_v2 || cookieObj.account_id_v2 || cookieObj.ltmid_v2;
114
- if (!ltuid) {
115
- return "\u53D1\u9001Cookie\u4E0D\u5B8C\u6574\uFF0C\u5EFA\u8BAE\u4F7F\u7528#\u626B\u7801\u767B\u5F55";
116
- }
218
+ if (!ltuid) return "\u53D1\u9001Cookie\u4E0D\u5B8C\u6574\uFF0C\u5EFA\u8BAE\u4F7F\u7528#\u7C73\u54C8\u6E38\u767B\u5F55\u3002";
117
219
  let cookieParams = {};
118
220
  let flagV2 = false;
119
221
  if (cookieObj.cookie_token_v2 && (cookieObj.account_mid_v2 || cookieObj.ltmid_v2)) {
@@ -137,32 +239,37 @@ var bingCookie = async (userId, cookie, Serv = "mihoyo" /* cn */) => {
137
239
  cookieParams.mi18nLang = cookieObj.mi18nLang;
138
240
  }
139
241
  const cookieStr = common_exports.ObjToStr(cookieParams, ";");
140
- let uidList = {
141
- Serv,
142
- uids: { data: {}, names: {} },
143
- message: "\u5237\u65B0UID\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF01"
144
- };
145
- for (const serv of Serv ? [Serv] : ["mihoyo" /* cn */, "hoyolab" /* os */]) {
146
- uidList = await UserInfo.refreshUid({
147
- type: serv,
148
- ltuid,
149
- cookie: cookieStr
150
- });
151
- if (!uidList.message) break;
152
- }
153
- if (uidList.message) {
154
- return uidList.message;
155
- }
156
- if (flagV2 && isNaN(Number(cookieParams.ltuid))) {
157
- const userFullInfo = await getUserFullInfo({
242
+ const uidList = await (async () => {
243
+ const errMsg = [];
244
+ for (const serv of Serv ? [Serv] : ["mihoyo" /* cn */, "hoyolab" /* os */]) {
245
+ const result = await UserInfo.refreshUid({
246
+ userId,
247
+ type: serv,
248
+ ltuid,
249
+ cookie: cookieStr,
250
+ deviceMd5: ""
251
+ }, perm);
252
+ if (!result.message) {
253
+ return result;
254
+ }
255
+ errMsg.push(result.message);
256
+ }
257
+ return {
258
+ Serv: Serv || "mihoyo" /* cn */,
259
+ uids: [],
260
+ message: errMsg.pop() || ""
261
+ };
262
+ })();
263
+ if (uidList.message) return uidList.message;
264
+ if (flagV2 && isNaN(+cookieParams.ltuid)) {
265
+ const userFullInfo = (await getUserFullInfo.init({
158
266
  type: uidList.Serv,
159
267
  ltuid,
160
- cookie: cookieStr
161
- }).request({});
162
- if (userFullInfo?.data?.user_info) {
163
- if (userFullInfo.data.user_info.uid) {
164
- cookieParams.ltuid = cookieParams.account_id = userFullInfo.data.user_info.uid;
165
- }
268
+ cookie: cookieStr,
269
+ deviceMd5: ""
270
+ }).request(null)).data;
271
+ if (userFullInfo.data.user_info.uid) {
272
+ cookieParams.ltuid = cookieParams.account_id = userFullInfo.data.user_info.uid;
166
273
  } else {
167
274
  logger.mark(`\u7ED1\u5B9ACookie\u9519\u8BEF2\uFF1A${userFullInfo?.message || "Cookie\u9519\u8BEF"}`);
168
275
  return `\u7ED1\u5B9ACookie\u5931\u8D25\uFF1A${userFullInfo?.message || "Cookie\u9519\u8BEF"}`;
@@ -170,72 +277,21 @@ var bingCookie = async (userId, cookie, Serv = "mihoyo" /* cn */) => {
170
277
  }
171
278
  const userInfo = await UserInfo.create(userId);
172
279
  await userInfo.saveUserInfo({
173
- userId,
174
- ...uidList.uids.data,
175
- ltuids: lodash.uniq([...userInfo.ltuids, cookieParams.ltuid]),
176
- stuids: userInfo.stuids,
177
- deviceList: userInfo.deviceList
280
+ ...uidList.uids.reduce((acc, cur) => {
281
+ acc[cur.columnKey] = cur.data;
282
+ return acc;
283
+ }, {}),
284
+ ltuids: userInfo.ltuids.add(cookieParams.ltuid, true)
178
285
  });
179
- const ltuidInfo = userInfo.getLtuidInfo(cookieParams.ltuid);
180
- await userInfo.saveMysAccountInfo({
181
- ltuid: cookieParams.ltuid,
286
+ await userInfo.saveMysAccountInfo(cookieParams.ltuid, {
182
287
  type: uidList.Serv,
183
- cookie: common_exports.ObjToStr(cookieParams, ";"),
184
- stoken: ltuidInfo?.stoken || "",
185
- deviceId: ltuidInfo?.deviceId || ""
288
+ cookie: common_exports.ObjToStr(cookieParams, ";")
186
289
  });
187
290
  logger.mark(`[${userId}] \u4FDD\u5B58Cookie\u6210\u529F [ltuid:${cookieParams.ltuid}]`);
188
- const sendMsg = [];
189
- lodash.forEach(uidList.uids.data, (uids, game) => {
190
- sendMsg.push(`\u3010${uidList.uids.names[game]}\u3011\uFF1A${uids.join("\u3001")}`);
191
- });
192
- return `Cookie\u7ED1\u5B9A\u6210\u529F\uFF01
193
- ${sendMsg.join("\n")}`;
194
- };
195
- var bingStoken = async (userId, stoken, option) => {
196
- const { cookie = "", Serv = "mihoyo" /* cn */ } = option || {};
197
- const stokenObj = common_exports.StrToObj(stoken.replace(/[#'" ]/g, ""), ";");
198
- if (!stokenObj.stoken || !(stokenObj.stuid || stokenObj.ltuid) || !stokenObj.mid) {
199
- return "\u53D1\u9001Stoken\u4E0D\u5B8C\u6574\uFF0C\u5EFA\u8BAE\u4F7F\u7528#\u626B\u7801\u767B\u5F55";
200
- }
201
- const stokenParams = {
202
- stuid: stokenObj.stuid || stokenObj.ltuid,
203
- stoken: stokenObj.stoken,
204
- mid: stokenObj.mid
205
- };
206
- let updata = { Serv, cookie, message: "" };
207
- if (!updata.cookie) {
208
- for (const serv of Serv ? [Serv] : ["mihoyo" /* cn */, "hoyolab" /* os */]) {
209
- updata = await UserInfo.refreshCookie(stokenParams, serv);
210
- if (updata.cookie) break;
211
- }
212
- if (updata.message) {
213
- return updata.message;
214
- }
215
- }
216
- const Stoken = common_exports.ObjToStr(stokenParams, ";");
217
- const userInfo = await UserInfo.create(userId);
218
- await userInfo.saveUserInfo({
219
- userId,
220
- ltuids: userInfo.ltuids,
221
- stuids: lodash.uniq([...userInfo.stuids, stokenParams.stuid]),
222
- deviceList: userInfo.deviceList
223
- });
224
- const ltuidInfo = userInfo.getLtuidInfo(stokenParams.stuid);
225
- await userInfo.saveMysAccountInfo({
226
- ltuid: stokenParams.stuid,
227
- type: updata.Serv,
228
- cookie: ltuidInfo?.cookie || "",
229
- stoken: Stoken,
230
- deviceId: ltuidInfo?.deviceId || ""
231
- });
232
- logger.mark(`[${userId}] \u4FDD\u5B58Stoken\u6210\u529F [stuid: ${stokenParams.stuid}]`);
233
- const sendMsg = [];
234
- sendMsg.push(`\u7C73\u6E38\u793EID\uFF1A${stokenParams.stuid}
235
- Stoken\u7ED1\u5B9A\u6210\u529F\uFF01`);
236
- sendMsg.push(await bingCookie(userId, updata.cookie, updata.Serv));
237
- return sendMsg.join("\n");
291
+ return false;
238
292
  };
239
293
  export {
294
+ BindCookieByMessage,
295
+ BindStokenByMessage,
240
296
  MiHoYoLoginQRCode
241
297
  };
@@ -0,0 +1,5 @@
1
+ import * as node_karin from 'node-karin';
2
+
3
+ declare const BindMysDevice: node_karin.Command<keyof node_karin.MessageEventMap>;
4
+
5
+ export { BindMysDevice };
@@ -0,0 +1,101 @@
1
+ import {
2
+ UserInfo
3
+ } from "../chunk-X75DW4KI.js";
4
+ import {
5
+ DeviceInfo
6
+ } from "../chunk-3CNBOOKY.js";
7
+ import "../chunk-3BIQN6QA.js";
8
+ import "../chunk-G5W5WAY5.js";
9
+ import "../chunk-7VAWV6ZE.js";
10
+ import "../chunk-LJSDSOY6.js";
11
+ import "../chunk-CFS2WFOO.js";
12
+ import "../chunk-MWYDWDR4.js";
13
+ import "../chunk-FOAQZIZ2.js";
14
+ import "../chunk-IVZICDGW.js";
15
+ import "../chunk-XQWTJIT4.js";
16
+ import "../chunk-7SZX3RBZ.js";
17
+ import "../chunk-W4DBT7AD.js";
18
+ import "../chunk-Z5I6A73Y.js";
19
+ import "../chunk-7WESXE4X.js";
20
+ import "../chunk-KN5SHBVI.js";
21
+ import "../chunk-QMSYS77M.js";
22
+ import "../chunk-SEWEEPJN.js";
23
+ import "../chunk-5NA7ZPDS.js";
24
+ import "../chunk-G547WVGV.js";
25
+ import "../chunk-EMAUATE3.js";
26
+ import "../chunk-Y3J3J5B2.js";
27
+ import "../chunk-7KEG6SDX.js";
28
+ import "../chunk-FBWSEBAW.js";
29
+ import "../chunk-JVJQKRJ4.js";
30
+ import "../chunk-LYTNREAI.js";
31
+ import "../chunk-K5U2O3HH.js";
32
+ import "../chunk-I7XZONDN.js";
33
+ import "../chunk-SHW6FHIB.js";
34
+ import "../chunk-JRH4JC43.js";
35
+ import "../chunk-ARLTXJFJ.js";
36
+ import "../chunk-LG34FPBI.js";
37
+ import "../chunk-HVYNK5BN.js";
38
+ import "../chunk-2DHTKQ34.js";
39
+ import "../chunk-SHLPPEAY.js";
40
+ import "../chunk-7YZHHLS5.js";
41
+ import "../chunk-6PIXUPZ6.js";
42
+ import "../chunk-MLKGABMK.js";
43
+
44
+ // src/apps/MysDevice.ts
45
+ import karin from "node-karin";
46
+ var BindMysDevice = karin.command(
47
+ /^#绑定(米游社|mys)?设备$/,
48
+ async (e) => {
49
+ const userInfo = await UserInfo.create(e.userId);
50
+ const ltuidInfoList = userInfo.LtuidInfoList;
51
+ const cnLtuidInfoList = ltuidInfoList.filter((info) => info.type === "mihoyo" /* cn */);
52
+ if (cnLtuidInfoList.length === 0) {
53
+ if (ltuidInfoList.length === 0) {
54
+ e.reply("\u6682\u672A\u7ED1\u5B9A\u56FD\u670D\u7C73\u6E38\u793E\u8D26\u53F7\uFF0C\u8BF7\u5148\u201C#\u7C73\u6E38\u793E\u7ED1\u5B9A\u201D\u8FDB\u884C\u7ED1\u5B9A\uFF01", { at: true });
55
+ } else {
56
+ e.reply("\u56FD\u9645\u670D\u6682\u4E0D\u9700\u8981\u7ED1\u5B9A\u8BBE\u5907\u3002", { at: true });
57
+ }
58
+ return true;
59
+ }
60
+ e.reply("\u8BF7\u53D1\u9001\u8BBE\u5907\u4FE1\u606F(\u5EFA\u8BAE\u79C1\u804A\u53D1\u9001)\uFF0C\u6216\u8005\u53D1\u9001\u201C\u53D6\u6D88\u201D\u53D6\u6D88\u7ED1\u5B9A", { at: true });
61
+ const ctx = await karin.ctx(e);
62
+ if (/^#?取消(绑定)?/.test(ctx.msg)) {
63
+ e.reply("\u5DF2\u53D6\u6D88\u7ED1\u5B9A", { at: true });
64
+ return true;
65
+ }
66
+ const device = JSON.parse(ctx.msg);
67
+ let deviceMD5 = "";
68
+ if (device.deviceName && device.deviceBoard && device.deviceModel && device.oaid && device.androidVersion && device.deviceFingerprint && device.deviceProduct) {
69
+ deviceMD5 = await DeviceInfo.create(e.userId, {
70
+ name: device.deviceName,
71
+ board: device.deviceBoard,
72
+ model: device.deviceModel,
73
+ oaid: device.oaid,
74
+ version: +device.androidVersion,
75
+ fingerprint: device.deviceFingerprint,
76
+ product: device.deviceProduct,
77
+ deviceId: device.device_id || crypto.randomUUID(),
78
+ deviceFp: device.device_fp || ""
79
+ });
80
+ } else if (device.device_id && device.device_fp) {
81
+ deviceMD5 = await DeviceInfo.create(e.userId, {
82
+ deviceId: device.device_id,
83
+ deviceFp: device.device_fp
84
+ });
85
+ } else {
86
+ e.reply("\u8BBE\u5907\u4FE1\u606F\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u63D0\u4F9B\u5B8C\u6574\u7684\u8BBE\u5907\u4FE1\u606F", { at: true });
87
+ return true;
88
+ }
89
+ await userInfo.saveUserInfo({
90
+ deviceList: userInfo.deviceList.add(deviceMD5, true)
91
+ });
92
+ return await ShowBindDeviceCmdFuc(e);
93
+ }
94
+ );
95
+ var ShowBindDeviceCmdFuc = async (e) => {
96
+ e.reply("\u8BBE\u5907\u7ED1\u5B9A\u6210\u529F", { at: true });
97
+ return true;
98
+ };
99
+ export {
100
+ BindMysDevice
101
+ };
@@ -0,0 +1,10 @@
1
+ import * as node_karin from 'node-karin';
2
+ import { Message } from 'node-karin';
3
+
4
+ declare const BindUID: node_karin.Command<keyof node_karin.MessageEventMap>;
5
+ declare const UnbindUID: node_karin.Command<keyof node_karin.MessageEventMap>;
6
+ declare const ShowBindAccountCmdFunc: (e: Message) => Promise<boolean>;
7
+ declare const ShowBindAccount: node_karin.Command<keyof node_karin.MessageEventMap>;
8
+ declare const UnbindAccount: node_karin.Command<keyof node_karin.MessageEventMap>;
9
+
10
+ export { BindUID, ShowBindAccount, ShowBindAccountCmdFunc, UnbindAccount, UnbindUID };
@@ -0,0 +1,52 @@
1
+ import {
2
+ BindUID,
3
+ ShowBindAccount,
4
+ ShowBindAccountCmdFunc,
5
+ UnbindAccount,
6
+ UnbindUID
7
+ } from "../chunk-JBGXPVO2.js";
8
+ import "../chunk-X75DW4KI.js";
9
+ import "../chunk-3CNBOOKY.js";
10
+ import "../chunk-3BIQN6QA.js";
11
+ import "../chunk-G5W5WAY5.js";
12
+ import "../chunk-7VAWV6ZE.js";
13
+ import "../chunk-LJSDSOY6.js";
14
+ import "../chunk-CFS2WFOO.js";
15
+ import "../chunk-MWYDWDR4.js";
16
+ import "../chunk-FOAQZIZ2.js";
17
+ import "../chunk-IVZICDGW.js";
18
+ import "../chunk-XQWTJIT4.js";
19
+ import "../chunk-7SZX3RBZ.js";
20
+ import "../chunk-W4DBT7AD.js";
21
+ import "../chunk-Z5I6A73Y.js";
22
+ import "../chunk-7WESXE4X.js";
23
+ import "../chunk-KN5SHBVI.js";
24
+ import "../chunk-QMSYS77M.js";
25
+ import "../chunk-SEWEEPJN.js";
26
+ import "../chunk-5NA7ZPDS.js";
27
+ import "../chunk-G547WVGV.js";
28
+ import "../chunk-EMAUATE3.js";
29
+ import "../chunk-Y3J3J5B2.js";
30
+ import "../chunk-7KEG6SDX.js";
31
+ import "../chunk-FBWSEBAW.js";
32
+ import "../chunk-JVJQKRJ4.js";
33
+ import "../chunk-LYTNREAI.js";
34
+ import "../chunk-K5U2O3HH.js";
35
+ import "../chunk-I7XZONDN.js";
36
+ import "../chunk-SHW6FHIB.js";
37
+ import "../chunk-JRH4JC43.js";
38
+ import "../chunk-ARLTXJFJ.js";
39
+ import "../chunk-LG34FPBI.js";
40
+ import "../chunk-HVYNK5BN.js";
41
+ import "../chunk-2DHTKQ34.js";
42
+ import "../chunk-SHLPPEAY.js";
43
+ import "../chunk-7YZHHLS5.js";
44
+ import "../chunk-6PIXUPZ6.js";
45
+ import "../chunk-MLKGABMK.js";
46
+ export {
47
+ BindUID,
48
+ ShowBindAccount,
49
+ ShowBindAccountCmdFunc,
50
+ UnbindAccount,
51
+ UnbindUID
52
+ };
@@ -0,0 +1,62 @@
1
+ declare class Config<C extends Record<string, any>> {
2
+ #private;
3
+ /**
4
+ * @param name 插件名称:配置名称
5
+ */
6
+ constructor(name: `${string}:${string}`, ConfigPath: string, DefaultConfig: C, IgnoreConfig: Record<string, any>);
7
+ loadConfig(): C;
8
+ mergeWithDefaults(userConfig: Record<string, any>, defaultConfig: Record<string, any>, IgnoreConfig: Record<string, any>): C;
9
+ /**
10
+ * @description 获取配置路径对应的默认配置
11
+ */
12
+ getDef<T>(path: string): T;
13
+ /**
14
+ * @description 获取配置路径对应的配置
15
+ */
16
+ get<T>(path: string, isArray?: false, def?: T): T;
17
+ get<T>(path: string, isArray: true, def?: T[]): EnhancedArray<T>;
18
+ /**
19
+ * @param save 是否立即保存
20
+ */
21
+ set<T>(path: string, value: T, save: boolean): void;
22
+ /**
23
+ * @description 立即保存配置
24
+ */
25
+ save(): void;
26
+ watch(): this;
27
+ }
28
+
29
+ declare class EnhancedArray<T> extends Array<T> {
30
+ #private;
31
+ constructor(cfg: Config<any>, items: T[], path: string);
32
+ /**
33
+ * @param element - string | number
34
+ * @returns
35
+ */
36
+ has(element: T & (string | number)): boolean;
37
+ /**
38
+ * @param isEqual 是否不添加重复元素
39
+ * @param save 是否立即保存
40
+ */
41
+ add(element: T, isEqual: boolean, save: boolean): this;
42
+ /**
43
+ * @param isEqual 是否不添加重复元素
44
+ * @param save 是否立即保存
45
+ */
46
+ addSome(elements: T[], isEqual: boolean, save: boolean): this;
47
+ /**
48
+ * @param predicate - 要删除的元素、删除条件函数或索引
49
+ * @param save - 是否立即保存
50
+ * @param isIndex - 当 predicate 为数字时,是否将其视为索引
51
+ */
52
+ remove(predicate: T & number, save: boolean, isIndex: true): this;
53
+ remove(predicate: T | ((item: T) => boolean), save: boolean): this;
54
+ /**
55
+ * @param predicate - 要删除的元素数组
56
+ * @param save - 是否立即保存
57
+ */
58
+ removeSome(elements: T[], save: boolean): this;
59
+ clear(): this;
60
+ }
61
+
62
+ export { Config as C, EnhancedArray as E };
File without changes
@@ -0,0 +1,27 @@
1
+ // src/exports/mys/user/game.ts
2
+ var MysGame = new class MysGame2 {
3
+ #games = /* @__PURE__ */ new Map();
4
+ get num() {
5
+ return this.#games.size;
6
+ }
7
+ match(prefix) {
8
+ if (!prefix || this.#games.size === 0) return void 0;
9
+ for (const Game of this.#games.values()) {
10
+ if (Game.prefix.test(prefix)) return Game;
11
+ }
12
+ return void 0;
13
+ }
14
+ RegisterGame(Game) {
15
+ this.#games.set(Game.columnKey, Game);
16
+ }
17
+ async forEachGame(fn) {
18
+ if (this.num === 0) return;
19
+ for (const Game of this.#games.values()) {
20
+ if (await fn(Game) === "break") break;
21
+ }
22
+ }
23
+ }();
24
+
25
+ export {
26
+ MysGame
27
+ };