onebots 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/server/app.js CHANGED
@@ -170,7 +170,7 @@ class App extends koa_1.default {
170
170
  ctx.body = e.message;
171
171
  }
172
172
  });
173
- this.router.get('/edit', (ctx, next) => {
173
+ this.router.post('/edit', (ctx, next) => {
174
174
  const { uin, ...config } = ctx.request.body;
175
175
  try {
176
176
  this.updateAccount(Number(uin), config);
@@ -59,7 +59,8 @@ export declare class CommonAction {
59
59
  };
60
60
  callLogin(this: V11, func: string, ...args: any[]): Promise<unknown>;
61
61
  submitSlider(this: V11, ticket: string): Promise<any>;
62
- login(this: V11, password?: string): any;
63
62
  submitSmsCode(this: V11, code: string): Promise<any>;
64
63
  sendSmsCode(this: V11): Promise<any>;
64
+ login(this: V11, password?: string): any;
65
+ logout(this: V11, keepalive?: boolean): Promise<unknown>;
65
66
  }
@@ -105,9 +105,6 @@ class CommonAction {
105
105
  async submitSlider(ticket) {
106
106
  return this.action.callLogin.apply(this, ['submitSlider', ticket]);
107
107
  }
108
- login(password) {
109
- return this.action.callLogin.apply(this, ['login', password]);
110
- }
111
108
  async submitSmsCode(code) {
112
109
  return this.action.callLogin.apply(this, ['submitSmsCode', code]);
113
110
  }
@@ -128,5 +125,18 @@ class CommonAction {
128
125
  this.client.sendSmsCode();
129
126
  });
130
127
  }
128
+ login(password) {
129
+ return this.action.callLogin.apply(this, ['login', password]);
130
+ }
131
+ logout(keepalive) {
132
+ return new Promise(async (resolve) => {
133
+ const receiveResult = (e) => {
134
+ this.client.off('system.offline', receiveResult);
135
+ resolve(e);
136
+ };
137
+ this.client.on('system.offline', receiveResult);
138
+ await this.client.logout(keepalive);
139
+ });
140
+ }
131
141
  }
132
142
  exports.CommonAction = CommonAction;
@@ -165,7 +165,7 @@ class V11 extends events_1.EventEmitter {
165
165
  }
166
166
  async stop(force) {
167
167
  if (this.client.status === oicq_1.OnlineStatus.Online) {
168
- await this.client.logout();
168
+ await this.client.terminate();
169
169
  }
170
170
  if (force) {
171
171
  (0, fs_1.rmSync)(this.client.dir, { force: true, recursive: true });
@@ -1,7 +1,6 @@
1
1
  import { V12 } from '../../../service/V12';
2
2
  import { OnlineStatus } from "oicq";
3
3
  import { Action } from "./";
4
- import { V11 } from "../../../service/V11";
5
4
  export declare class CommonAction {
6
5
  sendMsg(): void;
7
6
  /**
@@ -24,10 +23,11 @@ export declare class CommonAction {
24
23
  version: string;
25
24
  onebot_version: string;
26
25
  };
27
- callLogin(this: V11, func: string, ...args: any[]): Promise<unknown>;
28
- submitSlider(this: V11, ticket: string): Promise<any>;
29
- login(this: V11, password?: string): any;
30
- submitSmsCode(this: V11, code: string): Promise<any>;
26
+ callLogin(this: V12, func: string, ...args: any[]): Promise<unknown>;
27
+ submitSlider(this: V12, ticket: string): Promise<any>;
28
+ submitSmsCode(this: V12, code: string): Promise<any>;
31
29
  sendSmsCode(this: V12): Promise<any>;
30
+ login(this: V12, password?: string): any;
31
+ logout(this: V12, keepalive?: boolean): Promise<unknown>;
32
32
  getSupportedActions(this: V12): string[];
33
33
  }
@@ -66,9 +66,6 @@ class CommonAction {
66
66
  async submitSlider(ticket) {
67
67
  return this.action.callLogin.apply(this, ['submitSlider', ticket]);
68
68
  }
69
- login(password) {
70
- return this.action.callLogin.apply(this, ['login', password]);
71
- }
72
69
  async submitSmsCode(code) {
73
70
  return this.action.callLogin.apply(this, ['submitSmsCode', code]);
74
71
  }
@@ -89,6 +86,19 @@ class CommonAction {
89
86
  this.client.sendSmsCode();
90
87
  });
91
88
  }
89
+ login(password) {
90
+ return this.action.callLogin.apply(this, ['login', password]);
91
+ }
92
+ logout(keepalive) {
93
+ return new Promise(async (resolve) => {
94
+ const receiveResult = (e) => {
95
+ this.client.off('system.offline', receiveResult);
96
+ resolve(e);
97
+ };
98
+ this.client.on('system.offline', receiveResult);
99
+ await this.client.logout(keepalive);
100
+ });
101
+ }
92
102
  getSupportedActions() {
93
103
  return [...new Set((0, utils_1.getProperties)(this.action))].filter(key => {
94
104
  return key !== 'constructor';
@@ -201,7 +201,7 @@ class V12 extends events_1.EventEmitter {
201
201
  }
202
202
  async stop(force) {
203
203
  if (this.client.status === oicq_1.OnlineStatus.Online) {
204
- await this.client.logout();
204
+ await this.client.terminate();
205
205
  }
206
206
  if (force) {
207
207
  (0, fs_1.rmSync)(this.client.dir, { force: true, recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "基于oicq的多例oneBot实现",
5
5
  "main": "lib/index.js",
6
6
  "bin": {