koishi-plugin-prism-neo 0.0.10 → 0.0.12
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 +16 -10
- package/lib/service.d.ts +3 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -90,24 +90,26 @@ async function getLock({ ctx, config }, userId) {
|
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
__name(getLock, "getLock");
|
|
93
|
-
async function machinePowerOn({ ctx, config }, machineName, userId) {
|
|
93
|
+
async function machinePowerOn({ ctx, config }, machineName, userId, needLogin = true) {
|
|
94
94
|
return await ctx.http.post(
|
|
95
95
|
makeUrl(config.url, `/machine/power`),
|
|
96
96
|
{
|
|
97
97
|
machineName,
|
|
98
98
|
"powerState": true,
|
|
99
|
-
userId: `QQ:${userId}
|
|
99
|
+
userId: `QQ:${userId}`,
|
|
100
|
+
needLogin
|
|
100
101
|
}
|
|
101
102
|
);
|
|
102
103
|
}
|
|
103
104
|
__name(machinePowerOn, "machinePowerOn");
|
|
104
|
-
async function machinePowerOff({ ctx, config }, machineName, userId) {
|
|
105
|
+
async function machinePowerOff({ ctx, config }, machineName, userId, needLogin = true) {
|
|
105
106
|
return await ctx.http.post(
|
|
106
107
|
makeUrl(config.url, `/machine/power`),
|
|
107
108
|
{
|
|
108
109
|
machineName,
|
|
109
110
|
"powerState": false,
|
|
110
|
-
userId: `QQ:${userId}
|
|
111
|
+
userId: `QQ:${userId}`,
|
|
112
|
+
needLogin
|
|
111
113
|
}
|
|
112
114
|
);
|
|
113
115
|
}
|
|
@@ -164,11 +166,12 @@ async function redeem({ ctx, config }, code, userId) {
|
|
|
164
166
|
);
|
|
165
167
|
}
|
|
166
168
|
__name(redeem, "redeem");
|
|
167
|
-
async function insertCoin({ ctx, config }, alias, userId) {
|
|
169
|
+
async function insertCoin({ ctx, config }, alias, userId, force = false) {
|
|
168
170
|
return await ctx.http.post(
|
|
169
171
|
makeUrl(config.url, `/remote/${alias}/coin`),
|
|
170
172
|
{
|
|
171
|
-
userId: `QQ:${userId}
|
|
173
|
+
userId: `QQ:${userId}`,
|
|
174
|
+
force
|
|
172
175
|
}
|
|
173
176
|
);
|
|
174
177
|
}
|
|
@@ -183,7 +186,7 @@ var Config = import_koishi.Schema.object({
|
|
|
183
186
|
});
|
|
184
187
|
async function getUserName(session, userId) {
|
|
185
188
|
if (userId) {
|
|
186
|
-
return (await session.bot.getUser(userId)).name + `(${userId}
|
|
189
|
+
return (await session.bot.getUser(userId)).name + ` ( ${userId} )`;
|
|
187
190
|
} else {
|
|
188
191
|
return "匿名用户";
|
|
189
192
|
}
|
|
@@ -455,13 +458,15 @@ async function handleItemsCmd(context, user) {
|
|
|
455
458
|
__name(handleItemsCmd, "handleItemsCmd");
|
|
456
459
|
async function handleMachineOn(context, alias) {
|
|
457
460
|
if (!alias) return "请输入设备名";
|
|
458
|
-
|
|
461
|
+
let isAdmin = await context.ctx.permissions.check(context.config.admin, context.session);
|
|
462
|
+
const res = await machinePowerOn(context, alias, context.session.userId, !isAdmin);
|
|
459
463
|
return `${res.machine} 启动成功`;
|
|
460
464
|
}
|
|
461
465
|
__name(handleMachineOn, "handleMachineOn");
|
|
462
466
|
async function handleMachineOff(context, alias) {
|
|
463
467
|
if (!alias) return "请输入设备名";
|
|
464
|
-
|
|
468
|
+
let isAdmin = await context.ctx.permissions.check(context.config.admin, context.session);
|
|
469
|
+
const res = await machinePowerOff(context, alias, context.session.userId, !isAdmin);
|
|
465
470
|
return `${res.machine} 关闭成功`;
|
|
466
471
|
}
|
|
467
472
|
__name(handleMachineOff, "handleMachineOff");
|
|
@@ -534,7 +539,8 @@ async function handleRedeem(context, code) {
|
|
|
534
539
|
__name(handleRedeem, "handleRedeem");
|
|
535
540
|
async function handleCoin(context, alias) {
|
|
536
541
|
if (!alias) return "请输入设备名";
|
|
537
|
-
|
|
542
|
+
let isAdmin = await context.ctx.permissions.check(context.config.admin, context.session);
|
|
543
|
+
const res = await insertCoin(context, alias, context.session.userId, isAdmin);
|
|
538
544
|
return `已为 ${res.machineName} 投入 ${res.count} 个币`;
|
|
539
545
|
}
|
|
540
546
|
__name(handleCoin, "handleCoin");
|
package/lib/service.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export declare function getLock({ ctx, config }: ActionContext, userId: string):
|
|
|
11
11
|
password: string;
|
|
12
12
|
id: any;
|
|
13
13
|
}>;
|
|
14
|
-
export declare function machinePowerOn({ ctx, config }: ActionContext, machineName: string, userId: string): Promise<any>;
|
|
15
|
-
export declare function machinePowerOff({ ctx, config }: ActionContext, machineName: string, userId: string): Promise<any>;
|
|
14
|
+
export declare function machinePowerOn({ ctx, config }: ActionContext, machineName: string, userId: string, needLogin?: boolean): Promise<any>;
|
|
15
|
+
export declare function machinePowerOff({ ctx, config }: ActionContext, machineName: string, userId: string, needLogin?: boolean): Promise<any>;
|
|
16
16
|
export declare function getAllMachinePower({ ctx, config, session }: ActionContext): Promise<{
|
|
17
17
|
machine: string;
|
|
18
18
|
state: {
|
|
@@ -29,4 +29,4 @@ export declare function walletAdd({ ctx, config }: ActionContext, amount: number
|
|
|
29
29
|
export declare function walletDel({ ctx, config }: ActionContext, amount: number, userId: string): Promise<any>;
|
|
30
30
|
export declare function costOverwrite({ ctx, config }: ActionContext, amount: string, userId: string): Promise<any>;
|
|
31
31
|
export declare function redeem({ ctx, config }: ActionContext, code: string, userId: string): Promise<any>;
|
|
32
|
-
export declare function insertCoin({ ctx, config }: ActionContext, alias: string, userId: string): Promise<any>;
|
|
32
|
+
export declare function insertCoin({ ctx, config }: ActionContext, alias: string, userId: string, force?: boolean): Promise<any>;
|