onebots 0.4.25 → 0.4.26

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.
@@ -1,7 +1,6 @@
1
1
  import type { QQAdapter } from "../../adapters/qq";
2
2
  import { AxiosInstance } from "axios";
3
3
  import { WebSocket } from "ws";
4
- import { SessionManager } from "../../adapters/qq/sessionManager";
5
4
  import { OneBot } from "../../onebot";
6
5
  import { QQBot } from "../../adapters/qq/qqBot";
7
6
  export declare class Bot extends QQBot {
@@ -12,7 +11,6 @@ export declare class Bot extends QQBot {
12
11
  nickname: string;
13
12
  status: number;
14
13
  ws: WebSocket;
15
- sessionManager: SessionManager;
16
14
  constructor(oneBot: OneBot, appId: string, config: QQAdapter.Config['protocol']);
17
15
  init(): Promise<void>;
18
16
  stop(): void;
@@ -106,7 +106,7 @@ class QQAdapter extends adapter_1.Adapter {
106
106
  }
107
107
  toCqcode(version, messageArr) {
108
108
  return [].concat(messageArr).map(item => {
109
- const dataStr = Object.entries(item.data).map(([key, value]) => {
109
+ const dataStr = Object.entries(item).filter(([key]) => key !== 'type').map(([key, value]) => {
110
110
  // is Buffer
111
111
  if (value instanceof Buffer)
112
112
  return `${key}=${value.toString('base64')}`;
@@ -117,13 +117,13 @@ class QQAdapter extends adapter_1.Adapter {
117
117
  if (value instanceof Array)
118
118
  return `${key}=${value.map(v => JSON.stringify(v)).join(',')}`;
119
119
  // is String
120
- return `${key}=${item.data[key]}`;
120
+ return `${key}=${item[key]}`;
121
121
  });
122
122
  return `[CQ:${item.type},${dataStr.join(',')}]`;
123
123
  }).join('');
124
124
  }
125
125
  formatEventPayload(version, event, data) {
126
- return {
126
+ const result = {
127
127
  id: data.id,
128
128
  type: event,
129
129
  version: version,
@@ -135,6 +135,8 @@ class QQAdapter extends adapter_1.Adapter {
135
135
  platform: 'qq',
136
136
  ...data,
137
137
  };
138
+ delete data.bot;
139
+ return result;
138
140
  }
139
141
  async start(uin) {
140
142
  const startOneBots = [...this.oneBots.values()].filter(oneBot => {
@@ -5,11 +5,12 @@ import { Bot } from "./bot";
5
5
  export declare class Message {
6
6
  bot: Bot;
7
7
  sub_type: Message.SubType;
8
- get self_id(): string;
8
+ self_id: string;
9
9
  guild_id?: string;
10
10
  channel_id?: string;
11
11
  group_id?: string;
12
12
  message_id: string;
13
+ seq: number;
13
14
  sender: Message.Sender;
14
15
  user_id: string;
15
16
  constructor(bot: Bot, attrs: Partial<Message>);
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GuildMessageEvent = exports.DirectMessageEvent = exports.GroupMessageEvent = exports.PrivateMessageEvent = exports.Message = void 0;
4
- const qqBot_1 = require("./qqBot");
5
4
  const utils_1 = require("./utils");
6
5
  const crypto_1 = require("crypto");
6
+ const bot_1 = require("./bot");
7
7
  class Message {
8
- get self_id() {
9
- return this.bot.self_id;
10
- }
11
8
  constructor(bot, attrs) {
12
9
  this.bot = bot;
13
10
  Object.assign(this, attrs);
11
+ this.self_id = bot.self_id;
12
+ this.seq = attrs.seq || (0, crypto_1.randomInt)(1000000);
14
13
  }
15
14
  get [Symbol.unscopables]() {
16
15
  return {
@@ -20,7 +19,8 @@ class Message {
20
19
  toJSON() {
21
20
  return Object.fromEntries(Object.keys(this)
22
21
  .filter(key => {
23
- return typeof this[key] !== "function" && !(this[key] instanceof qqBot_1.QQBot);
22
+ console.log(key, typeof this[key]);
23
+ return typeof this[key] !== "function" && !(this[key] instanceof bot_1.Bot);
24
24
  })
25
25
  .map(key => [key, this[key]]));
26
26
  }
@@ -88,7 +88,9 @@ class QQBot extends events_1.EventEmitter {
88
88
  raw_message: brief,
89
89
  sender: {
90
90
  user_id: payload.author?.id,
91
- user_openid: payload.author?.user_openid || payload.author?.member_openid
91
+ nickname: payload.author?.name || '',
92
+ user_openid: payload.author?.user_openid || payload.author?.member_openid,
93
+ ...(payload.author || {})
92
94
  },
93
95
  timestamp: new Date(payload.timestamp).getTime() / 1000,
94
96
  });
@@ -40,5 +40,17 @@ qq.a: # `${适配器名称}:${账号}`
40
40
  - version: V11
41
41
  # 。。。其他配置项参见上方对应oneBot版本的通用配置
42
42
  protocol: # 将会覆盖通用配置中的protocol
43
- platform: 1
43
+ token: '' # qq机器人token
44
+ secret: '' # qq机器人secret
45
+ sandbox: false # 是否沙箱环境
46
+ intents: # 需要监听的intents
47
+ - 'GROUP_AT_MESSAGE_CREATE' # 群聊@事件 没有群聊权限请注释
48
+ - 'C2C_MESSAGE_CREATE' # 私聊事件 没有私聊权限请注释
49
+ - 'DIRECT_MESSAGE' # 频道私信事件
50
+ # - 'GUILD_MESSAGES' # 私域机器人频道消息事件,公域机器人请注释
51
+ - 'GUILDS' # 频道变更事件
52
+ - 'GUILD_MEMBERS' # 频道成员变更事件
53
+ - 'GUILD_MESSAGE_REACTIONS' # 频道消息表态事件
54
+ - 'INTERACTION' # 互动事件
55
+ - 'PUBLIC_GUILD_MESSAGES' # 公域机器人频道消息事件,私域机器人请注释
44
56
  # 。。。其他配置项参见上方对应oneBot版本的通用配置
@@ -314,6 +314,7 @@ class V11 extends service_1.Service {
314
314
  return JSON.stringify(data1);
315
315
  }
316
316
  else {
317
+ delete data.bot;
317
318
  return JSON.stringify(data);
318
319
  }
319
320
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.4.25",
3
+ "version": "0.4.26",
4
4
  "description": "基于icqq的多例oneBot实现",
5
5
  "engines": {
6
6
  "node": ">=16"