onebots 0.0.26 → 0.0.27

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/db.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from "events";
3
- export declare class Db extends EventEmitter {
1
+ export declare class Db {
4
2
  private readonly path;
5
3
  private data;
6
4
  private raw_data;
package/lib/db.js CHANGED
@@ -2,10 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Db = void 0;
4
4
  const fs_1 = require("fs");
5
- const events_1 = require("events");
6
- class Db extends events_1.EventEmitter {
5
+ class Db {
7
6
  constructor(path, force_create = true) {
8
- super();
9
7
  this.path = path;
10
8
  this.data = {};
11
9
  this.raw_data = '{}';
@@ -63,7 +61,7 @@ class Db extends events_1.EventEmitter {
63
61
  }
64
62
  write() {
65
63
  try {
66
- const raw_data = JSON.stringify(this.data, null, 2);
64
+ const raw_data = JSON.stringify(this.data);
67
65
  if (raw_data !== this.raw_data) {
68
66
  (0, fs_1.writeFileSync)(this.path, raw_data);
69
67
  this.raw_data = raw_data;
package/lib/server/app.js CHANGED
@@ -48,7 +48,7 @@ class App extends koa_1.default {
48
48
  super(config);
49
49
  this.oneBots = [];
50
50
  this.config = (0, utils_1.deepMerge)((0, utils_1.deepClone)(App.defaultConfig), config);
51
- this.logger = (0, log4js_1.getLogger)('[oicq-oneBot]');
51
+ this.logger = (0, log4js_1.getLogger)('[oicq-OneBot]');
52
52
  this.logger.level = this.config.log_level;
53
53
  this.router = new router_1.Router({ prefix: config.path });
54
54
  this.use((0, koa_bodyparser_1.default)())
@@ -58,7 +58,7 @@ class App extends koa_1.default {
58
58
  this.createOneBots();
59
59
  }
60
60
  getLogger(uin, version = '') {
61
- const logger = (0, log4js_1.getLogger)(`[oicq-oneBot${version}:${uin}]`);
61
+ const logger = (0, log4js_1.getLogger)(`[oicq-OneBot${version}:${uin}]`);
62
62
  logger.level = this.config.log_level;
63
63
  return logger;
64
64
  }
@@ -23,6 +23,7 @@ export declare class V12 extends EventEmitter implements OneBot.Base {
23
23
  private db;
24
24
  constructor(oneBot: OneBot<'V12'>, client: Client, config: V12.Config);
25
25
  get history(): Payload<keyof Action>[];
26
+ set history(value: Payload<keyof Action>[]);
26
27
  start(path?: string): void;
27
28
  private startHttp;
28
29
  private startWebhook;
@@ -28,13 +28,16 @@ class V12 extends events_1.EventEmitter {
28
28
  this.wsr = new Set();
29
29
  this.db = new db_1.Db((0, path_1.join)(app_1.App.configDir, 'data', this.client.uin + '.json'));
30
30
  if (!this.history)
31
- this.db.set('eventBuffer', []);
31
+ this.history = [];
32
32
  this.action = new action_1.Action();
33
33
  this.logger = this.oneBot.app.getLogger(this.client.uin, this.version);
34
34
  }
35
35
  get history() {
36
36
  return this.db.get('eventBuffer');
37
37
  }
38
+ set history(value) {
39
+ this.db.set('eventBuffer', value);
40
+ }
38
41
  start(path) {
39
42
  this.path = `/${this.client.uin}`;
40
43
  if (path)
@@ -261,6 +264,10 @@ class V12 extends events_1.EventEmitter {
261
264
  if (this.client.status === oicq_1.OnlineStatus.Online) {
262
265
  await this.client.terminate();
263
266
  }
267
+ this.wss.close();
268
+ for (const ws of this.wsr) {
269
+ ws.close();
270
+ }
264
271
  if (force) {
265
272
  (0, fs_1.rmSync)(this.client.dir, { force: true, recursive: true });
266
273
  }
@@ -357,6 +364,7 @@ class V12 extends events_1.EventEmitter {
357
364
  params[k] = (0, utils_1.toBool)(params[k]);
358
365
  if (k === 'message') {
359
366
  params[k] = V12.fromSegment(params[k]);
367
+ console.log(params[k]);
360
368
  params['message_id'] = params[k].find(e => e.type === 'reply')?.message_id;
361
369
  }
362
370
  args.push(params[k]);
@@ -564,6 +572,7 @@ exports.V12 = V12;
564
572
  const { type, data, ...other } = msg;
565
573
  return {
566
574
  type: type.replace('mention', 'at').replace('at_all', 'at'),
575
+ qq: data['user_id'],
567
576
  ...other,
568
577
  ...data
569
578
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "基于oicq的多例oneBot实现",
5
5
  "engines": {
6
6
  "node": ">=16"