onebots 0.4.39 → 0.4.41

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.
@@ -204,11 +204,11 @@ class DingtalkAdapter extends adapter_1.Adapter {
204
204
  [version === 'V12' ? 'type' : 'post_type']: event,
205
205
  version: version,
206
206
  self: {
207
- platform: 'qq',
207
+ platform: 'dingtalk',
208
208
  user_id: data.self_id
209
209
  },
210
210
  detail_type: data.message_type || data.notice_type || data.request_type,
211
- platform: 'qq',
211
+ platform: 'dingtalk',
212
212
  time: data.timestamp,
213
213
  ...data,
214
214
  };
@@ -196,15 +196,20 @@ class WechatAdapter extends adapter_1.Adapter {
196
196
  [version === 'V12' ? 'type' : 'post_type']: event,
197
197
  version: version,
198
198
  self: {
199
- platform: 'qq',
199
+ platform: 'wechat',
200
200
  user_id: data.self_id
201
201
  },
202
202
  detail_type: data.message_type || data.notice_type || data.request_type,
203
- platform: 'qq',
203
+ platform: 'wechat',
204
+ group: data.group?.info,
205
+ member: data.member?.info,
206
+ friend: data.friend?.info,
204
207
  time: data.timestamp,
205
208
  ...data,
206
209
  };
207
210
  delete result.bot;
211
+ delete result.c;
212
+ delete result.parser;
208
213
  return result;
209
214
  }
210
215
  async start(uin) {
package/lib/server/app.js CHANGED
@@ -180,7 +180,7 @@ class App extends koa_1.default {
180
180
  process_1.default.on('disconnect', () => {
181
181
  fs.unwatchFile(App.logFile, fileListener);
182
182
  });
183
- this.ws.on('connection', (client) => {
183
+ this.ws.on('connection', async (client) => {
184
184
  client.send(JSON.stringify({
185
185
  event: 'system.sync',
186
186
  data: {
@@ -189,7 +189,7 @@ class App extends koa_1.default {
189
189
  return adapter.info;
190
190
  }),
191
191
  app: this.info,
192
- logs: fs.existsSync(App.logFile) ? fs.readFileSync(App.logFile, 'utf8') : ''
192
+ logs: fs.existsSync(App.logFile) ? await (0, utils_1.readLine)(100, App.logFile, 'utf8') : ''
193
193
  }
194
194
  }));
195
195
  client.on('message', async (raw) => {
@@ -359,9 +359,9 @@ class V12 extends service_1.Service {
359
359
  id: (0, utils_2.uuid)(),
360
360
  impl: 'onebots',
361
361
  version: 12,
362
- platform: 'qq',
362
+ platform: this.oneBot.platform,
363
363
  self: {
364
- platform: 'qq',
364
+ platform: this.oneBot.platform,
365
365
  user_id: `${this.oneBot.uin}`
366
366
  },
367
367
  };
@@ -372,7 +372,7 @@ class V12 extends service_1.Service {
372
372
  }), {
373
373
  self_id: `${this.oneBot.uin}`,
374
374
  self: {
375
- platform: 'qq',
375
+ platform: this.oneBot.platform,
376
376
  user_id: `${this.oneBot.uin}`
377
377
  },
378
378
  });
@@ -579,7 +579,7 @@ class V12 extends service_1.Service {
579
579
  const headers = {
580
580
  "X-Self-ID": String(this.oneBot.uin),
581
581
  "X-Client-Role": "Universal",
582
- "User-Agent": "OneBot/12 (qq) Node-onebots/" + utils_1.version,
582
+ "User-Agent": `OneBot/12 (${this.oneBot.platform}) Node-onebots/V12`,
583
583
  "Sec-WebSocket-Protocol": "12.onebots.v" + utils_1.version
584
584
  };
585
585
  if (config.access_token)
package/lib/utils.d.ts CHANGED
@@ -1,5 +1,8 @@
1
+ /// <reference types="node" />
1
2
  import { Dict } from "@zhinjs/shared";
3
+ import * as fs from "fs";
2
4
  export declare const version: any;
5
+ export declare function readLine(maxLen: number, ...params: Parameters<typeof fs.createReadStream>): Promise<string[]>;
3
6
  export declare function deepMerge(base: any, ...from: any[]): any;
4
7
  export declare function transformObj(obj: any, callback: any): any;
5
8
  export declare function deepClone<T extends any>(obj: T): T;
package/lib/utils.js CHANGED
@@ -23,10 +23,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.stringifyObj = exports.parseObjFromStr = exports.getDataKeyOfObj = exports.getValueOfObj = exports.setValueToObj = exports.getProperties = exports.protectedFields = exports.randomInt = exports.uuid = exports.toBool = exports.remove = exports.toHump = exports.Mixin = exports.toLine = exports.omit = exports.pick = exports.deepClone = exports.transformObj = exports.deepMerge = exports.version = void 0;
26
+ exports.stringifyObj = exports.parseObjFromStr = exports.getDataKeyOfObj = exports.getValueOfObj = exports.setValueToObj = exports.getProperties = exports.protectedFields = exports.randomInt = exports.uuid = exports.toBool = exports.remove = exports.toHump = exports.Mixin = exports.toLine = exports.omit = exports.pick = exports.deepClone = exports.transformObj = exports.deepMerge = exports.readLine = exports.version = void 0;
27
27
  const crypto = __importStar(require("crypto"));
28
+ const fs = __importStar(require("fs"));
29
+ const readline = __importStar(require("readline"));
28
30
  const packageJson = require('../package.json');
29
31
  exports.version = packageJson.version;
32
+ function readLine(maxLen, ...params) {
33
+ return new Promise(resolve => {
34
+ const result = [];
35
+ const rl = readline.createInterface({
36
+ input: fs.createReadStream(...params),
37
+ crlfDelay: Infinity
38
+ });
39
+ rl.on('line', (line) => {
40
+ result.push(line);
41
+ if (result.length > maxLen)
42
+ result.shift();
43
+ });
44
+ rl.on('close', () => {
45
+ resolve(result);
46
+ });
47
+ });
48
+ }
49
+ exports.readLine = readLine;
30
50
  // 合并对象/数组
31
51
  function deepMerge(base, ...from) {
32
52
  if (base === null || base === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.4.39",
3
+ "version": "0.4.41",
4
4
  "description": "基于icqq的多例oneBot实现",
5
5
  "engines": {
6
6
  "node": ">=16"