koishi-plugin-ggcevo-game 0.4.7 → 0.4.9
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 -0
- package/lib/index.js +65 -21
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface Config {
|
|
|
7
7
|
signrequire: boolean;
|
|
8
8
|
autorank: boolean;
|
|
9
9
|
ignoreGlobalLimit: boolean;
|
|
10
|
+
admins: string[];
|
|
10
11
|
}
|
|
11
12
|
export declare const Config: Schema<Config>;
|
|
12
13
|
export declare const inject: {
|
|
@@ -66,6 +67,7 @@ export interface rank {
|
|
|
66
67
|
name: string;
|
|
67
68
|
rank: number;
|
|
68
69
|
matches: number;
|
|
70
|
+
Blacklist: boolean;
|
|
69
71
|
}
|
|
70
72
|
export interface Punishment {
|
|
71
73
|
id: number;
|
package/lib/index.js
CHANGED
|
@@ -34,7 +34,8 @@ var Config = import_koishi.Schema.object({
|
|
|
34
34
|
ggcqun: import_koishi.Schema.string().description("开启咕咕虫排行榜的群组").required(),
|
|
35
35
|
signrequire: import_koishi.Schema.boolean().description("是否开启签到要求进行一场游戏").default(true),
|
|
36
36
|
autorank: import_koishi.Schema.boolean().description("是否开启每小时自动同步rank数据").default(true),
|
|
37
|
-
ignoreGlobalLimit: import_koishi.Schema.boolean().description("是否开启无限制兑换").default(false)
|
|
37
|
+
ignoreGlobalLimit: import_koishi.Schema.boolean().description("是否开启无限制兑换").default(false),
|
|
38
|
+
admins: import_koishi.Schema.array(import_koishi.Schema.string()).description("管理员QQ号列表,支持配置多个").default([]).role("table")
|
|
38
39
|
});
|
|
39
40
|
var inject = {
|
|
40
41
|
required: ["database"]
|
|
@@ -96,8 +97,13 @@ function apply(ctx, config) {
|
|
|
96
97
|
// 玩家名称
|
|
97
98
|
rank: "integer",
|
|
98
99
|
// rank分数(带正负)
|
|
99
|
-
matches: "unsigned"
|
|
100
|
+
matches: "unsigned",
|
|
100
101
|
// 比赛次数
|
|
102
|
+
Blacklist: {
|
|
103
|
+
type: "boolean",
|
|
104
|
+
// 该字段的默认值
|
|
105
|
+
initial: false
|
|
106
|
+
}
|
|
101
107
|
}, {
|
|
102
108
|
primary: ["regionId", "realmId", "profileId"]
|
|
103
109
|
// 复合主键
|
|
@@ -234,7 +240,7 @@ function apply(ctx, config) {
|
|
|
234
240
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
235
241
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
236
242
|
if (existingEntries.length > 0) {
|
|
237
|
-
return
|
|
243
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
238
244
|
}
|
|
239
245
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
240
246
|
if (!backpack) {
|
|
@@ -273,7 +279,7 @@ function apply(ctx, config) {
|
|
|
273
279
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
274
280
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
275
281
|
if (existingEntries.length > 0) {
|
|
276
|
-
return
|
|
282
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
277
283
|
}
|
|
278
284
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
279
285
|
if (!backpack) {
|
|
@@ -306,7 +312,7 @@ function apply(ctx, config) {
|
|
|
306
312
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
307
313
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
308
314
|
if (existingEntries.length > 0) {
|
|
309
|
-
return
|
|
315
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
310
316
|
}
|
|
311
317
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
312
318
|
if (!backpack) {
|
|
@@ -380,7 +386,7 @@ ${itemDetails.join("\n")}`;
|
|
|
380
386
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
381
387
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
382
388
|
if (existingEntries.length > 0) {
|
|
383
|
-
return
|
|
389
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
384
390
|
}
|
|
385
391
|
if (config.signrequire) {
|
|
386
392
|
const getconfig = {
|
|
@@ -456,7 +462,7 @@ ${itemDetails.join("\n")}`;
|
|
|
456
462
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
457
463
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
458
464
|
if (existingEntries.length > 0) {
|
|
459
|
-
return
|
|
465
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
460
466
|
}
|
|
461
467
|
const [record] = await ctx.database.get("ggcevo_sign", { handle });
|
|
462
468
|
if (!record) return "请先完成一次正常签到后再进行补签。";
|
|
@@ -535,7 +541,7 @@ ${itemDetails.join("\n")}`;
|
|
|
535
541
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
536
542
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
537
543
|
if (existingEntries.length > 0) {
|
|
538
|
-
return
|
|
544
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
539
545
|
}
|
|
540
546
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
541
547
|
if (!backpack) return "您还没有签到过哦";
|
|
@@ -582,7 +588,7 @@ ${itemDetails.join("\n")}`;
|
|
|
582
588
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
583
589
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
584
590
|
if (existingEntries.length > 0) {
|
|
585
|
-
return
|
|
591
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
586
592
|
}
|
|
587
593
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 1 });
|
|
588
594
|
if (!backpack) return "您还没有签到过哦";
|
|
@@ -823,8 +829,8 @@ ID:${activity.id}
|
|
|
823
829
|
if (pageNum < 1) return "请输入有效的页码。";
|
|
824
830
|
const offset = (pageNum - 1) * 10;
|
|
825
831
|
const [records, total] = await Promise.all([
|
|
826
|
-
ctx.database.select("ggcevo_rank").orderBy("rank", "desc").limit(10).offset(offset).execute(),
|
|
827
|
-
ctx.database.select("ggcevo_rank").execute((row) => import_koishi.$.count(row.profileId))
|
|
832
|
+
ctx.database.select("ggcevo_rank").where({ Blacklist: false }).orderBy("rank", "desc").limit(10).offset(offset).execute(),
|
|
833
|
+
ctx.database.select("ggcevo_rank").where({ Blacklist: false }).execute((row) => import_koishi.$.count(row.profileId))
|
|
828
834
|
]);
|
|
829
835
|
const pageSize = 10;
|
|
830
836
|
const totalPages = Math.ceil(total / pageSize);
|
|
@@ -839,7 +845,7 @@ ID:${activity.id}
|
|
|
839
845
|
(item, index) => `${offset + index + 1}. ${item.displayName} | 积分: ${item.rank} | 参赛: ${item.matches} 次`
|
|
840
846
|
).join("\n");
|
|
841
847
|
return [
|
|
842
|
-
`🏆 GGCEvo 胜点榜 🏆`,
|
|
848
|
+
`🏆 GGCEvo 胜点榜 (S1赛季至3月31日结算) 🏆`,
|
|
843
849
|
`第 ${pageNum} 页 共 ${totalPages} 页`,
|
|
844
850
|
"------------------------------",
|
|
845
851
|
rankingText,
|
|
@@ -861,7 +867,8 @@ ID:${activity.id}
|
|
|
861
867
|
profileId
|
|
862
868
|
});
|
|
863
869
|
if (!user) return "未找到您的排名信息。";
|
|
864
|
-
|
|
870
|
+
if (user.Blacklist) return "❌您已经被禁止参加本赛季胜点榜。";
|
|
871
|
+
const allRanks = await ctx.database.select("ggcevo_rank").where({ Blacklist: false }).orderBy("rank", "desc").execute();
|
|
865
872
|
const userRank = allRanks.findIndex(
|
|
866
873
|
(u) => u.regionId === regionId && u.realmId === realmId && u.profileId === profileId
|
|
867
874
|
) + 1;
|
|
@@ -893,7 +900,8 @@ ID:${activity.id}
|
|
|
893
900
|
profileId
|
|
894
901
|
});
|
|
895
902
|
if (!user) return "未找到他/她的排名信息。";
|
|
896
|
-
|
|
903
|
+
if (user.Blacklist) return "❌他/她已经被禁止参加本赛季胜点榜。";
|
|
904
|
+
const allRanks = await ctx.database.select("ggcevo_rank").where({ Blacklist: false }).orderBy("rank", "desc").execute();
|
|
897
905
|
const userRank = allRanks.findIndex(
|
|
898
906
|
(u) => u.regionId === regionId && u.realmId === realmId && u.profileId === profileId
|
|
899
907
|
) + 1;
|
|
@@ -1032,7 +1040,7 @@ ${items.join("、")}
|
|
|
1032
1040
|
const handle = `${profile.regionId}-S2-${profile.realmId}-${profile.profileId}`;
|
|
1033
1041
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1034
1042
|
if (existingEntries.length > 0) {
|
|
1035
|
-
return
|
|
1043
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
1036
1044
|
}
|
|
1037
1045
|
const configname = itemConfig[name2];
|
|
1038
1046
|
if (!configname) return "无效的物品名称,请重新输入";
|
|
@@ -1120,7 +1128,7 @@ ${output}`;
|
|
|
1120
1128
|
const handle = `${profile.regionId}-S2-${profile.realmId}-${profile.profileId}`;
|
|
1121
1129
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1122
1130
|
if (existingEntries.length > 0) {
|
|
1123
|
-
return
|
|
1131
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
1124
1132
|
}
|
|
1125
1133
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 3 });
|
|
1126
1134
|
const [coupon] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 2 });
|
|
@@ -1149,7 +1157,7 @@ ${output}`;
|
|
|
1149
1157
|
const handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
1150
1158
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1151
1159
|
if (existingEntries.length > 0) {
|
|
1152
|
-
return
|
|
1160
|
+
return `❌拒绝访问,您已被列入活动黑名单。`;
|
|
1153
1161
|
}
|
|
1154
1162
|
const [backpack] = await ctx.database.get("ggcevo_backpack", { handle, itemId: 3 });
|
|
1155
1163
|
if (!backpack || backpack.quantity < 1) {
|
|
@@ -1177,8 +1185,14 @@ ${output}`;
|
|
|
1177
1185
|
}]);
|
|
1178
1186
|
return `🎉 恭喜获得:${itemName}`;
|
|
1179
1187
|
});
|
|
1180
|
-
ctx.command("ggcevo
|
|
1181
|
-
|
|
1188
|
+
ctx.command("ggcevo/活动拉黑", "添加用户到活动黑名单").action(async (argv) => {
|
|
1189
|
+
const session = argv.session;
|
|
1190
|
+
if (!ctx.config.admins.includes(session.userId)) {
|
|
1191
|
+
return "⚠️ 没有操作权限,请联系机器人管理员";
|
|
1192
|
+
}
|
|
1193
|
+
await session.send("请在30秒内输入需要拉黑的句柄:\n(句柄格式为: [区域ID]-S2-[服务器ID]-[档案ID])");
|
|
1194
|
+
const handle = await session.prompt(3e4);
|
|
1195
|
+
if (!handle) return "输入超时,请重新输入指令。";
|
|
1182
1196
|
try {
|
|
1183
1197
|
const handleRegex = /^([1235])-S2-([12])-(\d+)$/;
|
|
1184
1198
|
if (!handleRegex.test(handle)) {
|
|
@@ -1186,13 +1200,43 @@ ${output}`;
|
|
|
1186
1200
|
}
|
|
1187
1201
|
const existingEntries = await ctx.database.get("ggcevo_blacklist", { handle });
|
|
1188
1202
|
if (existingEntries.length > 0) {
|
|
1189
|
-
return `${handle}
|
|
1203
|
+
return `${handle} 已在活动黑名单中`;
|
|
1190
1204
|
}
|
|
1191
1205
|
await ctx.database.create("ggcevo_blacklist", {
|
|
1192
1206
|
handle,
|
|
1193
1207
|
createdAt: /* @__PURE__ */ new Date()
|
|
1194
1208
|
});
|
|
1195
|
-
return `✅ 用户 ${handle}
|
|
1209
|
+
return `✅ 用户 ${handle} 已被列入活动黑名单(永久)`;
|
|
1210
|
+
} catch (error) {
|
|
1211
|
+
console.error("黑名单操作失败:", error);
|
|
1212
|
+
return "操作失败,请稍后重试。错误详情已记录";
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
ctx.command("ggcevo/胜点榜拉黑", "添加用户到胜点榜黑名单").action(async (argv) => {
|
|
1216
|
+
const session = argv.session;
|
|
1217
|
+
if (!ctx.config.admins.includes(session.userId)) {
|
|
1218
|
+
return "⚠️ 没有操作权限,请联系机器人管理员";
|
|
1219
|
+
}
|
|
1220
|
+
await session.send("请在30秒内输入需要拉黑的句柄:\n(句柄格式为: [区域ID]-S2-[服务器ID]-[档案ID])");
|
|
1221
|
+
const handle = await session.prompt(3e4);
|
|
1222
|
+
if (!handle) return "输入超时,请重新输入指令。";
|
|
1223
|
+
try {
|
|
1224
|
+
const handleRegex = /^([1235])-S2-([12])-(\d+)$/;
|
|
1225
|
+
if (!handleRegex.test(handle)) {
|
|
1226
|
+
return "句柄格式错误,请重新输入";
|
|
1227
|
+
}
|
|
1228
|
+
const [, regionId, realmId, profileId] = handle.match(handleRegex).map(Number);
|
|
1229
|
+
const existingEntries = await ctx.database.get("ggcevo_rank", { regionId, realmId, profileId, Blacklist: true });
|
|
1230
|
+
if (existingEntries.length > 0) {
|
|
1231
|
+
return `${handle} 已在胜点榜黑名单中`;
|
|
1232
|
+
}
|
|
1233
|
+
await ctx.database.upsert("ggcevo_rank", [{
|
|
1234
|
+
regionId,
|
|
1235
|
+
realmId,
|
|
1236
|
+
profileId,
|
|
1237
|
+
Blacklist: true
|
|
1238
|
+
}]);
|
|
1239
|
+
return `✅ 用户 ${handle} 已被列入胜点榜黑名单(仅限当前赛季)`;
|
|
1196
1240
|
} catch (error) {
|
|
1197
1241
|
console.error("黑名单操作失败:", error);
|
|
1198
1242
|
return "操作失败,请稍后重试。错误详情已记录";
|