koishi-plugin-ggcevo-game 0.3.22 → 0.4.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.
- package/lib/index.d.ts +2 -1
- package/lib/index.js +53 -19
- package/package.json +2 -2
- package/readme.md +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface Config {
|
|
|
6
6
|
ggcqun: string;
|
|
7
7
|
signrequire: boolean;
|
|
8
8
|
autorank: boolean;
|
|
9
|
+
ignoreGlobalLimit: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const Config: Schema<Config>;
|
|
11
12
|
export declare const inject: {
|
|
@@ -83,6 +84,7 @@ export interface exchange {
|
|
|
83
84
|
item: string;
|
|
84
85
|
type: string;
|
|
85
86
|
date: Date;
|
|
87
|
+
GlobalLimit: boolean;
|
|
86
88
|
}
|
|
87
89
|
export interface adminbenefit {
|
|
88
90
|
userId: string;
|
|
@@ -91,7 +93,6 @@ export interface adminbenefit {
|
|
|
91
93
|
lastSign: Date;
|
|
92
94
|
}
|
|
93
95
|
export interface blacklist {
|
|
94
|
-
userId: string;
|
|
95
96
|
handle: string;
|
|
96
97
|
createdAt: Date;
|
|
97
98
|
}
|
package/lib/index.js
CHANGED
|
@@ -33,7 +33,8 @@ var Config = import_koishi.Schema.object({
|
|
|
33
33
|
proxyAgent: import_koishi.Schema.string().description("代理服务器地址"),
|
|
34
34
|
ggcqun: import_koishi.Schema.string().description("开启咕咕虫排行榜的群组").required(),
|
|
35
35
|
signrequire: import_koishi.Schema.boolean().description("是否开启签到要求每日一场").default(true),
|
|
36
|
-
autorank: import_koishi.Schema.boolean().description("是否开启每小时自动同步rank数据").default(true)
|
|
36
|
+
autorank: import_koishi.Schema.boolean().description("是否开启每小时自动同步rank数据").default(true),
|
|
37
|
+
ignoreGlobalLimit: import_koishi.Schema.boolean().description("是否开启无限制兑换").default(false)
|
|
37
38
|
});
|
|
38
39
|
var inject = {
|
|
39
40
|
required: ["database"]
|
|
@@ -135,7 +136,8 @@ function apply(ctx, config) {
|
|
|
135
136
|
item: "string",
|
|
136
137
|
// 兑换物品
|
|
137
138
|
type: "string",
|
|
138
|
-
date: "timestamp"
|
|
139
|
+
date: "timestamp",
|
|
140
|
+
GlobalLimit: "boolean"
|
|
139
141
|
}, {
|
|
140
142
|
// 额外配置
|
|
141
143
|
primary: ["handle", "item"]
|
|
@@ -149,16 +151,15 @@ function apply(ctx, config) {
|
|
|
149
151
|
lastSign: "timestamp"
|
|
150
152
|
}, {
|
|
151
153
|
// 额外配置
|
|
152
|
-
primary: "
|
|
154
|
+
primary: "handle"
|
|
153
155
|
});
|
|
154
156
|
ctx.model.extend("ggcevo_blacklist", {
|
|
155
157
|
// 各字段定义
|
|
156
|
-
userId: "string",
|
|
157
158
|
handle: "string",
|
|
158
159
|
createdAt: "timestamp"
|
|
159
160
|
}, {
|
|
160
161
|
// 额外配置
|
|
161
|
-
primary: "
|
|
162
|
+
primary: "handle"
|
|
162
163
|
});
|
|
163
164
|
const initDefaultItems = {
|
|
164
165
|
"咕咕币": { id: 1, type: "抽奖道具", description: "用于进行抽奖" },
|
|
@@ -240,6 +241,10 @@ function apply(ctx, config) {
|
|
|
240
241
|
}
|
|
241
242
|
const { regionId, realmId, profileId } = profile;
|
|
242
243
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
244
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
245
|
+
if (existingEntries.length > 0) {
|
|
246
|
+
return `${handle} 已被加入黑名单。`;
|
|
247
|
+
}
|
|
243
248
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
244
249
|
if (!backpack) {
|
|
245
250
|
return "您还没有进行过签到。";
|
|
@@ -275,6 +280,10 @@ function apply(ctx, config) {
|
|
|
275
280
|
}
|
|
276
281
|
const { regionId, realmId, profileId } = profile;
|
|
277
282
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
283
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
284
|
+
if (existingEntries.length > 0) {
|
|
285
|
+
return `${handle} 已被加入黑名单。`;
|
|
286
|
+
}
|
|
278
287
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
279
288
|
if (!backpack) {
|
|
280
289
|
return "您还没有进行过签到。";
|
|
@@ -304,6 +313,10 @@ function apply(ctx, config) {
|
|
|
304
313
|
}
|
|
305
314
|
const { regionId, realmId, profileId } = profile;
|
|
306
315
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
316
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
317
|
+
if (existingEntries.length > 0) {
|
|
318
|
+
return `${handle} 已被加入黑名单。`;
|
|
319
|
+
}
|
|
307
320
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
308
321
|
if (!backpack) {
|
|
309
322
|
return "您还没有进行过签到。";
|
|
@@ -374,6 +387,10 @@ ${itemDetails.join("\n")}`;
|
|
|
374
387
|
}
|
|
375
388
|
const { regionId, realmId, profileId } = profile;
|
|
376
389
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
390
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
391
|
+
if (existingEntries.length > 0) {
|
|
392
|
+
return `${handle} 已被加入黑名单。`;
|
|
393
|
+
}
|
|
377
394
|
if (config.signrequire) {
|
|
378
395
|
const getconfig = {
|
|
379
396
|
url: `https://api.sc2arcade.com/profiles/${regionId}/${realmId}/${profileId}/matches?orderDirection=desc`,
|
|
@@ -446,6 +463,10 @@ ${itemDetails.join("\n")}`;
|
|
|
446
463
|
if (!profile) return "您的 QQ 未绑定句柄。";
|
|
447
464
|
const { regionId, realmId, profileId } = profile;
|
|
448
465
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
466
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
467
|
+
if (existingEntries.length > 0) {
|
|
468
|
+
return `${handle} 已被加入黑名单。`;
|
|
469
|
+
}
|
|
449
470
|
const [record] = await ctx.database.get("ggcevo_sign", { handle });
|
|
450
471
|
if (!record) return "请先完成一次正常签到后再进行补签。";
|
|
451
472
|
const lastSignChina = convertUTCtoChinaTime(new Date(record.lastSign));
|
|
@@ -521,6 +542,10 @@ ${itemDetails.join("\n")}`;
|
|
|
521
542
|
if (!profile) return "您的 QQ 未绑定句柄。";
|
|
522
543
|
const { regionId, realmId, profileId } = profile;
|
|
523
544
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
545
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
546
|
+
if (existingEntries.length > 0) {
|
|
547
|
+
return `${handle} 已被加入黑名单。`;
|
|
548
|
+
}
|
|
524
549
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
525
550
|
if (!backpack) return "您还没有签到过哦";
|
|
526
551
|
const memberInfo = await session.event?.member?.roles;
|
|
@@ -564,6 +589,10 @@ ${itemDetails.join("\n")}`;
|
|
|
564
589
|
if (!profile) return "您的 QQ 未绑定句柄。";
|
|
565
590
|
const { regionId, realmId, profileId } = profile;
|
|
566
591
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
592
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
593
|
+
if (existingEntries.length > 0) {
|
|
594
|
+
return `${handle} 已被加入黑名单。`;
|
|
595
|
+
}
|
|
567
596
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
568
597
|
if (!backpack) return "您还没有签到过哦";
|
|
569
598
|
const [activity] = await ctx.database.get("ggcevo_activity", {
|
|
@@ -998,12 +1027,16 @@ ${items.join("、")}
|
|
|
998
1027
|
const name2 = await session.prompt(3e4);
|
|
999
1028
|
if (!name2) return "输入超时,请重新输入指令。";
|
|
1000
1029
|
const handle = `${profile.regionId}-S2-${profile.realmId}-${profile.profileId}`;
|
|
1030
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1031
|
+
if (existingEntries.length > 0) {
|
|
1032
|
+
return `${handle} 已被加入黑名单。`;
|
|
1033
|
+
}
|
|
1001
1034
|
const configname = itemConfig[name2];
|
|
1002
1035
|
if (!configname) return "无效的物品名称,请重新输入";
|
|
1003
1036
|
const userRecords = await ctx.database.get("ggcevo_exchange", { handle, item: name2 });
|
|
1004
1037
|
if (userRecords.length > 0) return "您已经兑换过该物品";
|
|
1005
|
-
if (configname.quantity !== void 0) {
|
|
1006
|
-
const globalRecords = await ctx.database.get("ggcevo_exchange", { item: name2 });
|
|
1038
|
+
if (configname.quantity !== void 0 && config.ignoreGlobalLimit === false) {
|
|
1039
|
+
const globalRecords = await ctx.database.get("ggcevo_exchange", { item: name2, GlobalLimit: true });
|
|
1007
1040
|
if (globalRecords.length >= configname.quantity) return "该物品已被兑换尽了";
|
|
1008
1041
|
}
|
|
1009
1042
|
const qualityMap = { "t3": 4, "t2": 5, "t1": 6, "t0": 7 };
|
|
@@ -1031,6 +1064,7 @@ ${items.join("、")}
|
|
|
1031
1064
|
return `${requireMsg}
|
|
1032
1065
|
当前持有:${coupon?.quantity || 0}个${couponName}`;
|
|
1033
1066
|
}
|
|
1067
|
+
const isGlobal = config.ignoreGlobalLimit === false;
|
|
1034
1068
|
await ctx.database.withTransaction(async () => {
|
|
1035
1069
|
await ctx.database.set(
|
|
1036
1070
|
"ggcevo_backpack",
|
|
@@ -1043,7 +1077,9 @@ ${items.join("、")}
|
|
|
1043
1077
|
item: name2,
|
|
1044
1078
|
type: configname.type,
|
|
1045
1079
|
// 从配置中获取类型
|
|
1046
|
-
date: /* @__PURE__ */ new Date()
|
|
1080
|
+
date: /* @__PURE__ */ new Date(),
|
|
1081
|
+
GlobalLimit: isGlobal
|
|
1082
|
+
// 关键字段设置
|
|
1047
1083
|
});
|
|
1048
1084
|
});
|
|
1049
1085
|
return `兑换成功!消耗 ${cost} 个${couponName}获得【${name2}】`;
|
|
@@ -1079,6 +1115,10 @@ ${output}`;
|
|
|
1079
1115
|
const [profile] = await ctx.database.get("sc2arcade_player", { userId: session.userId });
|
|
1080
1116
|
if (!profile) return "您的 QQ 未绑定句柄";
|
|
1081
1117
|
const handle = `${profile.regionId}-S2-${profile.realmId}-${profile.profileId}`;
|
|
1118
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1119
|
+
if (existingEntries.length > 0) {
|
|
1120
|
+
return `${handle} 已被加入黑名单。`;
|
|
1121
|
+
}
|
|
1082
1122
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 3 });
|
|
1083
1123
|
const [coupon] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 2 });
|
|
1084
1124
|
if (!coupon || coupon.quantity < 3) {
|
|
@@ -1104,6 +1144,10 @@ ${output}`;
|
|
|
1104
1144
|
}
|
|
1105
1145
|
const { regionId, realmId, profileId } = profile;
|
|
1106
1146
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
1147
|
+
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1148
|
+
if (existingEntries.length > 0) {
|
|
1149
|
+
return `${handle} 已被加入黑名单。`;
|
|
1150
|
+
}
|
|
1107
1151
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 3 });
|
|
1108
1152
|
if (!backpack || backpack.quantity < 1) {
|
|
1109
1153
|
return `当前扭蛋币不足,剩余:${backpack?.quantity || 0}枚`;
|
|
@@ -1137,27 +1181,17 @@ ${output}`;
|
|
|
1137
1181
|
if (!handleRegex.test(handle)) {
|
|
1138
1182
|
return "句柄格式错误,请重新输入";
|
|
1139
1183
|
}
|
|
1140
|
-
const [, regionId, realmId, profileId] = handle.match(handleRegex).map(Number);
|
|
1141
1184
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1142
1185
|
if (existingEntries.length > 0) {
|
|
1143
1186
|
return `${handle} 已在黑名单中`;
|
|
1144
1187
|
}
|
|
1145
|
-
const [profile] = await ctx.database.get("sc2arcade_player", {
|
|
1146
|
-
regionId,
|
|
1147
|
-
realmId,
|
|
1148
|
-
profileId
|
|
1149
|
-
}, ["userId"]);
|
|
1150
|
-
if (!profile) {
|
|
1151
|
-
return `未找到与 ${handle} 绑定的QQ号`;
|
|
1152
|
-
}
|
|
1153
1188
|
await ctx.database.create("ggcevo_blacklist", {
|
|
1154
|
-
userId: profile.userId,
|
|
1155
1189
|
handle,
|
|
1156
1190
|
createdAt: /* @__PURE__ */ new Date()
|
|
1157
1191
|
});
|
|
1158
1192
|
return `✅ 用户 ${handle} 已被列入黑名单`;
|
|
1159
1193
|
} catch (error) {
|
|
1160
|
-
|
|
1194
|
+
console.error("黑名单操作失败:", error);
|
|
1161
1195
|
return "操作失败,请稍后重试。错误详情已记录";
|
|
1162
1196
|
}
|
|
1163
1197
|
});
|
package/package.json
CHANGED
package/readme.md
CHANGED