koishi-plugin-ggcevo-game 0.4.5 → 0.4.7
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 +30 -33
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -103,7 +103,6 @@ function apply(ctx, config) {
|
|
|
103
103
|
// 复合主键
|
|
104
104
|
});
|
|
105
105
|
ctx.model.extend("ggcevo_Punishment", {
|
|
106
|
-
// 各字段定义
|
|
107
106
|
id: "unsigned",
|
|
108
107
|
// 自增序号
|
|
109
108
|
name: "string",
|
|
@@ -123,13 +122,11 @@ function apply(ctx, config) {
|
|
|
123
122
|
comment: "text"
|
|
124
123
|
// 备注信息(可选)
|
|
125
124
|
}, {
|
|
126
|
-
// 额外配置
|
|
127
125
|
primary: "id",
|
|
128
126
|
autoInc: true
|
|
129
127
|
// 启用自增ID
|
|
130
128
|
});
|
|
131
129
|
ctx.model.extend("ggcevo_exchange", {
|
|
132
|
-
// 各字段定义
|
|
133
130
|
userId: "string",
|
|
134
131
|
handle: "string",
|
|
135
132
|
// 句柄
|
|
@@ -139,26 +136,20 @@ function apply(ctx, config) {
|
|
|
139
136
|
date: "timestamp",
|
|
140
137
|
GlobalLimit: "boolean"
|
|
141
138
|
}, {
|
|
142
|
-
// 额外配置
|
|
143
139
|
primary: ["handle", "item"]
|
|
144
140
|
});
|
|
145
141
|
ctx.model.extend("ggcevo_adminbenefit", {
|
|
146
|
-
// 各字段定义
|
|
147
142
|
userId: "string",
|
|
148
143
|
handle: "string",
|
|
149
|
-
// 句柄
|
|
150
144
|
signmonth: "unsigned",
|
|
151
145
|
lastSign: "timestamp"
|
|
152
146
|
}, {
|
|
153
|
-
// 额外配置
|
|
154
147
|
primary: "userId"
|
|
155
148
|
});
|
|
156
149
|
ctx.model.extend("ggcevo_blacklist", {
|
|
157
|
-
// 各字段定义
|
|
158
150
|
handle: "string",
|
|
159
151
|
createdAt: "timestamp"
|
|
160
152
|
}, {
|
|
161
|
-
// 额外配置
|
|
162
153
|
primary: "handle"
|
|
163
154
|
});
|
|
164
155
|
const initDefaultItems = {
|
|
@@ -677,7 +668,7 @@ ID:${activity.id}
|
|
|
677
668
|
hour12: false
|
|
678
669
|
}), "formatTime");
|
|
679
670
|
const output = activities.map((activity) => [
|
|
680
|
-
|
|
671
|
+
`活动: ${activity.name}`,
|
|
681
672
|
`时间:${formatTime(activity.startTime)} ~ ${formatTime(activity.endTime)}`,
|
|
682
673
|
`描述:${activity.description}`,
|
|
683
674
|
`奖励:${activity.quantity} 枚咕咕币`,
|
|
@@ -831,27 +822,30 @@ ID:${activity.id}
|
|
|
831
822
|
const pageNum = parseInt(page) || 1;
|
|
832
823
|
if (pageNum < 1) return "请输入有效的页码。";
|
|
833
824
|
const offset = (pageNum - 1) * 10;
|
|
834
|
-
const records = await
|
|
835
|
-
|
|
825
|
+
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))
|
|
828
|
+
]);
|
|
829
|
+
const pageSize = 10;
|
|
830
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
831
|
+
if (pageNum > totalPages) return `最多有 ${totalPages} 页`;
|
|
836
832
|
const processedRecords = await Promise.all(
|
|
837
|
-
records.map(async (item) => {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
displayName: isSafe ? item.name : (item.name[0] || "") + "***"
|
|
842
|
-
// 处理空名字的情况
|
|
843
|
-
};
|
|
844
|
-
})
|
|
833
|
+
records.map(async (item) => ({
|
|
834
|
+
...item,
|
|
835
|
+
displayName: await checkSensitiveWord(item.name) ? item.name : (item.name[0] || "") + "***"
|
|
836
|
+
}))
|
|
845
837
|
);
|
|
846
|
-
const rankingText = processedRecords.map(
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
838
|
+
const rankingText = processedRecords.map(
|
|
839
|
+
(item, index) => `${offset + index + 1}. ${item.displayName} | 积分: ${item.rank} | 参赛: ${item.matches} 次`
|
|
840
|
+
).join("\n");
|
|
841
|
+
return [
|
|
842
|
+
`🏆 GGCEvo 胜点榜 🏆`,
|
|
843
|
+
`第 ${pageNum} 页 共 ${totalPages} 页`,
|
|
844
|
+
"------------------------------",
|
|
845
|
+
rankingText,
|
|
846
|
+
"------------------------------",
|
|
847
|
+
pageNum < totalPages ? `输入 胜点榜 ${pageNum + 1} 查看下一页` : "已是最后一页"
|
|
848
|
+
].join("\n");
|
|
855
849
|
});
|
|
856
850
|
ctx.command("ggcevo/排名 [player]", "查询个人排名").alias("rank").usage("输入“排名”查看自己的排名信息").action(async (argv, player) => {
|
|
857
851
|
const session = argv.session;
|
|
@@ -936,8 +930,10 @@ ID:${activity.id}
|
|
|
936
930
|
return "操作失败,请稍后再试";
|
|
937
931
|
}
|
|
938
932
|
});
|
|
939
|
-
ctx.command("ggcevo/违规记录 [
|
|
933
|
+
ctx.command("ggcevo/违规记录 [user]", "违规记录查询").usage("输入 违规记录 [@用户] -p 页码 查看处罚记录,每页1条").option("p", "-p <page:number> 指定页码").action(async (argv) => {
|
|
940
934
|
const session = argv.session;
|
|
935
|
+
const pageNum = argv.options.p ? argv.options.p : 1;
|
|
936
|
+
const user = argv.args[0];
|
|
941
937
|
let handle;
|
|
942
938
|
if (!user) {
|
|
943
939
|
const [profile] = await ctx.database.get("sc2arcade_player", { userId: session.userId });
|
|
@@ -957,8 +953,8 @@ ID:${activity.id}
|
|
|
957
953
|
const { regionId, realmId, profileId } = profile;
|
|
958
954
|
handle = `${regionId}-S2-${realmId}-${profileId}`;
|
|
959
955
|
}
|
|
960
|
-
const pageNum = parseInt(page) || 1;
|
|
961
956
|
if (pageNum < 1) return "请输入有效的页码。";
|
|
957
|
+
const totalPages = await ctx.database.select("ggcevo_Punishment").where({ handle }).execute((row) => import_koishi.$.count(row.id));
|
|
962
958
|
const records = await ctx.database.select("ggcevo_Punishment").where({ handle }).orderBy("id", "desc").limit(1).offset(pageNum - 1).execute();
|
|
963
959
|
if (!records.length) {
|
|
964
960
|
return pageNum === 1 ? `【${handle}】暂无违规记录` : `【${handle}】第 ${pageNum} 条记录不存在`;
|
|
@@ -979,11 +975,12 @@ ID:${activity.id}
|
|
|
979
975
|
return finalText;
|
|
980
976
|
}).join("\n------------------------------\n");
|
|
981
977
|
return [
|
|
982
|
-
`🚨 违规记录
|
|
978
|
+
`🚨 违规记录 🚨`,
|
|
979
|
+
`第 ${pageNum} 条 共 ${totalPages} 条`,
|
|
983
980
|
"------------------------------",
|
|
984
981
|
recordText,
|
|
985
982
|
"------------------------------",
|
|
986
|
-
`输入 违规记录 ${pageNum + 1} 查看下一条`
|
|
983
|
+
pageNum < totalPages ? `输入 违规记录 -p ${pageNum + 1} 查看下一条` : "已是最后一页"
|
|
987
984
|
].join("\n");
|
|
988
985
|
});
|
|
989
986
|
const itemConfig = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-ggcevo-game",
|
|
3
3
|
"description": "星际争霸2游戏大厅咕咕虫-Evo地图专属插件",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.7",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"koishi": "^4.18.7",
|
|
19
19
|
"@koishijs/plugin-proxy-agent": "^0.3.3",
|
|
20
|
-
"koishi-plugin-sc2arcade-search": "^0.3
|
|
20
|
+
"koishi-plugin-sc2arcade-search": "^1.0.3"
|
|
21
21
|
},
|
|
22
22
|
"koishi": {
|
|
23
23
|
"service": {
|