koishi-plugin-18xx 0.0.5 → 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.
- package/lib/index.js +12 -1
- package/package.json +1 -1
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),
|