koishi-plugin-18xx 0.0.4 → 0.0.6

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 (2) hide show
  1. package/lib/index.js +12 -1
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -99,8 +99,19 @@ function command(ctx, config) {
99
99
  if (!found) return "";
100
100
  }
101
101
  }, "checkSessionMiddleware");
102
- ctx.command("18xx.bind <id>", "绑定账号").usage("id 是个人资料页地址栏 profile 后面的数字").before(checkSessionMiddleware).action(async ({ session }, id) => {
102
+ ctx.command("18xx.bind <id>", "绑定账号").option("force", "-f", { authority: 4 }).usage("id 是个人资料页地址栏 profile 后面的数字").before(checkSessionMiddleware).action(async ({ session, options }, id) => {
103
103
  if (Number(id)) {
104
+ if (!options.force) {
105
+ const profiles = await ctx.database.get(name, { id: Number(id) });
106
+ if (profiles.length) {
107
+ if (profiles.length > 1) {
108
+ logger.error(`${id} 绑定了多个账号`, profiles, session);
109
+ }
110
+ if (profiles[0].userId !== session.userId) {
111
+ return `${id} 已被其他用户绑定`;
112
+ }
113
+ }
114
+ }
104
115
  const result = await ctx.database.upsert(name, [
105
116
  {
106
117
  id: Number(id),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-18xx",
3
3
  "description": "18xxGames 机器人",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@koishijs/plugin-server": "^3.2.7",
31
- "@satorijs/element": "*",
31
+ "@satorijs/element": "^3.1.8",
32
32
  "koishi": "^4.18.7"
33
33
  },
34
34
  "koishi": {