koishi-plugin-prism-neo 0.0.7 → 0.0.10

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 ADDED
@@ -0,0 +1,8 @@
1
+ import { Context, Schema } from 'koishi';
2
+ export declare const name = "prism-neo";
3
+ export interface Config {
4
+ url: string;
5
+ admin: string;
6
+ }
7
+ export declare const Config: Schema<Config>;
8
+ export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -164,6 +164,15 @@ async function redeem({ ctx, config }, code, userId) {
164
164
  );
165
165
  }
166
166
  __name(redeem, "redeem");
167
+ async function insertCoin({ ctx, config }, alias, userId) {
168
+ return await ctx.http.post(
169
+ makeUrl(config.url, `/remote/${alias}/coin`),
170
+ {
171
+ userId: `QQ:${userId}`
172
+ }
173
+ );
174
+ }
175
+ __name(insertCoin, "insertCoin");
167
176
 
168
177
  // src/index.ts
169
178
  var name = "prism-neo";
@@ -523,6 +532,12 @@ async function handleRedeem(context, code) {
523
532
  return message.join("\n");
524
533
  }
525
534
  __name(handleRedeem, "handleRedeem");
535
+ async function handleCoin(context, alias) {
536
+ if (!alias) return "请输入设备名";
537
+ const res = await insertCoin(context, alias, context.session.userId);
538
+ return `已为 ${res.machineName} 投入 ${res.count} 个币`;
539
+ }
540
+ __name(handleCoin, "handleCoin");
526
541
  function apply(ctx, config) {
527
542
  const createAction = /* @__PURE__ */ __name((handler) => {
528
543
  const actionFn = /* @__PURE__ */ __name((argv, ...args) => {
@@ -547,6 +562,7 @@ function apply(ctx, config) {
547
562
  ctx.command("on <alias>").action(createAction(handleMachineOn));
548
563
  ctx.command("off <alias>").action(createAction(handleMachineOff));
549
564
  ctx.command("redeem <code>").action(createAction(handleRedeem));
565
+ ctx.command("coin <alias>").action(createAction(handleCoin));
550
566
  ctx.command("add <user:user> <amount>").action(createAction(handleWalletAdd));
551
567
  ctx.command("del <user:user> <amount>").action(createAction(handleWalletDeduct));
552
568
  ctx.command("overwrite <user:user> <amount>").action(createAction(handleCostOverwrite));
@@ -0,0 +1,32 @@
1
+ import { ActionContext } from "./types";
2
+ import { BillingResponse, ListResponse, LogoutResponse, UserAsset, Wallet } from "./model";
3
+ export declare function register({ ctx, config }: ActionContext, userId: string): Promise<unknown>;
4
+ export declare function login({ ctx, config }: ActionContext, userId: string): Promise<unknown>;
5
+ export declare function logout({ ctx, config }: ActionContext, userId: string): Promise<LogoutResponse>;
6
+ export declare function billing({ ctx, config }: ActionContext, userId: string): Promise<BillingResponse>;
7
+ export declare function list({ ctx, config }: ActionContext): Promise<ListResponse>;
8
+ export declare function wallet({ ctx, config }: ActionContext, userId: string): Promise<Wallet>;
9
+ export declare function assets({ ctx, config }: ActionContext, userId: string): Promise<UserAsset[]>;
10
+ export declare function getLock({ ctx, config }: ActionContext, userId: string): Promise<{
11
+ password: string;
12
+ id: any;
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>;
16
+ export declare function getAllMachinePower({ ctx, config, session }: ActionContext): Promise<{
17
+ machine: string;
18
+ state: {
19
+ state: boolean;
20
+ };
21
+ }[]>;
22
+ export declare function getMachinePower({ ctx, config, session }: ActionContext, machineName: string): Promise<{
23
+ machine: string;
24
+ state: {
25
+ state: boolean;
26
+ };
27
+ }>;
28
+ export declare function walletAdd({ ctx, config }: ActionContext, amount: number, userId: string): Promise<any>;
29
+ export declare function walletDel({ ctx, config }: ActionContext, amount: number, userId: string): Promise<any>;
30
+ export declare function costOverwrite({ ctx, config }: ActionContext, amount: string, userId: string): Promise<any>;
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>;
package/lib/types.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { Context, Session } from 'koishi';
2
+ import { Config } from './index';
3
+ export interface ActionContext {
4
+ ctx: Context;
5
+ config: Config;
6
+ session: Session;
7
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-prism-neo",
3
3
  "description": "prism koishi前端",
4
- "version": "0.0.7",
4
+ "version": "0.0.10",
5
5
  "main": "lib/index.js",
6
6
  "files": [
7
7
  "lib",