onebots 0.4.59 → 0.4.61

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.
@@ -6,14 +6,14 @@ export declare class GroupAction {
6
6
  * @param message {V12.Sendable} 消息
7
7
  * @param source {source} 引用消息id
8
8
  */
9
- sendGroupMsg(this: V12, group_id: number, message: V12.Sendable, source?: string): Promise<V12.MessageRet>;
9
+ sendGroupMsg(this: V12, group_id: string, message: V12.Sendable, source?: string): Promise<V12.MessageRet>;
10
10
  /**
11
11
  * 群组踢人
12
12
  * @param group_id {number} 群id
13
13
  * @param user_id {number} 成员id
14
14
  * @param reject_add_request {boolean} 是否禁止此人加群请求
15
15
  */
16
- setGroupKick(this: V12, group_id: number, user_id: number, reject_add_request?: boolean): Promise<any>;
16
+ setGroupKick(this: V12, group_id: string, user_id: string, reject_add_request?: boolean): Promise<any>;
17
17
  /**
18
18
  * 设置群精华
19
19
  * @param message_id
@@ -23,63 +23,64 @@ export declare class GroupAction {
23
23
  * 移除群精华
24
24
  * @param message_id
25
25
  */
26
- deleteEssenceMessage(this: V12, message_id: string): Promise<any>;
26
+ removeEssenceMessage(this: V12, message_id: string): Promise<any>;
27
27
  /**
28
28
  * 群打卡
29
29
  * @param group_id 群id
30
30
  */
31
- sendGroupSign(this: V12, group_id: number): Promise<any>;
31
+ sendGroupSign(this: V12, group_id: string): Promise<any>;
32
32
  /**
33
33
  * 群禁言指定人
34
34
  * @param group_id {number} 群id
35
35
  * @param user_id {number} 成员id
36
36
  * @param duration {number} 禁言时长(单位:秒)
37
37
  */
38
- setGroupBan(this: V12, group_id: number, user_id: number, duration?: number): Promise<any>;
38
+ setGroupBan(this: V12, group_id: string, user_id: string, duration?: number): Promise<any>;
39
39
  /**
40
40
  * 群禁言匿名者
41
41
  * @param group_id {number} 群id
42
42
  * @param flag {string} 匿名者flag
43
43
  * @param duration {number} 禁言时长(单位:秒)
44
44
  */
45
- setGroupAnonymousBan(this: V12, group_id: number, flag: string, duration?: number): Promise<any>;
45
+ setGroupAnonymousBan(this: V12, group_id: string, flag: string, duration?: number): Promise<any>;
46
46
  /**
47
47
  * 群全体禁言
48
48
  * @param group_id {number} 群id
49
49
  * @param enable {boolean} 是否禁言
50
50
  */
51
- setGroupWholeBan(this: V12, group_id: number, enable?: boolean): Promise<any>;
51
+ setGroupWholeBan(this: V12, group_id: string, enable?: boolean): Promise<any>;
52
52
  /**
53
53
  * 群匿名聊天
54
54
  * @param group_id {number} 群id
55
55
  * @param enable {boolean} 是否开启
56
56
  */
57
- setGroupAnonymous(this: V12, group_id: number, enable?: boolean): Promise<any>;
57
+ setGroupAnonymous(this: V12, group_id: string, enable?: boolean): Promise<any>;
58
58
  /**
59
59
  * 设置群管
60
60
  * @param group_id {number} 群id
61
61
  * @param user_id {number} 成员id
62
62
  * @param enable {boolean} true 设为管理,false 取消管理
63
63
  */
64
- setGroupAdmin(this: V12, group_id: number, user_id: number, enable?: boolean): Promise<any>;
64
+ setGroupAdmin(this: V12, group_id: string, user_id: string, enable?: boolean): Promise<any>;
65
65
  /**
66
66
  * 设置群成员名片(成员备注)
67
67
  * @param group_id {number} 群id
68
68
  * @param user_id {number} 成员id
69
69
  * @param card {string} 名片信息,不传或传空串则为 删除名片
70
70
  */
71
- setGroupCard(this: V12, group_id: number, user_id: number, card?: string): Promise<any>;
71
+ setGroupCard(this: V12, group_id: string, user_id: string, card?: string): Promise<any>;
72
72
  /**
73
73
  * 设置群名
74
74
  * @param group_id {number} 群id
75
75
  * @param name {string} 新群名
76
76
  */
77
- setGroupName(this: V12, group_id: number, name: string): Promise<any>;
77
+ setGroupName(this: V12, group_id: string, name: string): Promise<any>;
78
+ sendGroupPoke(this: V12, group_id: string, user_id: string): Promise<any>;
78
79
  /**
79
80
  * 退出指定群聊
80
81
  * @param group_id {number} 群id
81
82
  */
82
- leaveGroup(this: V12, group_id: number): Promise<any>;
83
+ leaveGroup(this: V12, group_id: string): Promise<any>;
83
84
  /**
84
85
  * 设置群成员头衔
85
86
  * @param group_id {number} 群id
@@ -87,7 +88,7 @@ export declare class GroupAction {
87
88
  * @param special_title {string} 头衔
88
89
  * @param duration {number} 持有时长 不传则永久
89
90
  */
90
- setGroupSpecialTitle(this: V12, group_id: number, user_id: number, special_title: string, duration?: number): Promise<any>;
91
+ setGroupSpecialTitle(this: V12, group_id: string, user_id: string, special_title: string, duration?: number): Promise<any>;
91
92
  /**
92
93
  * 处理加群请求
93
94
  * @param flag {string} 加群flag
@@ -104,16 +105,22 @@ export declare class GroupAction {
104
105
  * 获取指定群信息
105
106
  * @param group_id
106
107
  */
107
- getGroupInfo(this: V12, group_id: number): Promise<any>;
108
+ getGroupInfo(this: V12, group_id: string): Promise<any>;
108
109
  /**
109
110
  * 获取群成员列表
110
111
  * @param group_id
111
112
  */
112
- getGroupMemberList(this: V12, group_id: number): Promise<any>;
113
+ getGroupMemberList(this: V12, group_id: string): Promise<any>;
113
114
  /**
114
115
  * 获取指定群成员信息
115
116
  * @param group_id
116
117
  * @param user_id
117
118
  */
118
- getGroupMemberInfo(this: V12, group_id: number, user_id: number): Promise<any>;
119
+ getGroupMemberInfo(this: V12, group_id: string, user_id: string): Promise<any>;
120
+ /**
121
+ * 设置群公告
122
+ * @param group_id
123
+ * @param content
124
+ */
125
+ sendGroupNotice(this: V12, group_id: string, content: string): Promise<any>;
119
126
  }
@@ -39,8 +39,8 @@ class GroupAction {
39
39
  * 移除群精华
40
40
  * @param message_id
41
41
  */
42
- deleteEssenceMessage(message_id) {
43
- return this.adapter.call(this.oneBot.uin, "V12", "deleteEssenceMessage", [message_id]);
42
+ removeEssenceMessage(message_id) {
43
+ return this.adapter.call(this.oneBot.uin, "V12", "removeEssenceMessage", [message_id]);
44
44
  }
45
45
  /**
46
46
  * 群打卡
@@ -121,6 +121,9 @@ class GroupAction {
121
121
  setGroupName(group_id, name) {
122
122
  return this.adapter.call(this.oneBot.uin, "V12", "setGroupName", [group_id, name]);
123
123
  }
124
+ sendGroupPoke(group_id, user_id) {
125
+ return this.adapter.call(this.oneBot.uin, "V12", "sendGroupPoke", [group_id, user_id]);
126
+ }
124
127
  /**
125
128
  * 退出指定群聊
126
129
  * @param group_id {number} 群id
@@ -186,5 +189,13 @@ class GroupAction {
186
189
  getGroupMemberInfo(group_id, user_id) {
187
190
  return this.adapter.call(this.oneBot.uin, "V12", "getGroupMemberInfo", [group_id, user_id]);
188
191
  }
192
+ /**
193
+ * 设置群公告
194
+ * @param group_id
195
+ * @param content
196
+ */
197
+ sendGroupNotice(group_id, content) {
198
+ return this.adapter.call(this.oneBot.uin, "V12", "sendGroupNotice", [group_id, content]);
199
+ }
189
200
  }
190
201
  exports.GroupAction = GroupAction;
@@ -67,76 +67,6 @@ export declare class V12 extends Service<"V12"> implements OneBot.Base {
67
67
  protected _webSocketHandler(ws: WebSocket): void;
68
68
  }
69
69
  export declare namespace V12 {
70
- type Sendable = string | SegmentElem | (string | SegmentElem)[];
71
- interface SegmentMap {
72
- face: {
73
- id: number;
74
- text?: string;
75
- };
76
- text: {
77
- text: string;
78
- };
79
- mention: {
80
- user_id: string;
81
- };
82
- rps: {
83
- id?: string;
84
- };
85
- dice: {
86
- id?: string;
87
- };
88
- poke: {
89
- user_id: string;
90
- };
91
- mention_all: null;
92
- image: {
93
- file_id: string;
94
- };
95
- voice: {
96
- file_id: string;
97
- };
98
- audio: {
99
- file_id: string;
100
- };
101
- file: {
102
- file_id: string;
103
- };
104
- music: {
105
- type: "163" | "qq" | "xm" | "custom";
106
- id?: string;
107
- url?: string;
108
- audio?: string;
109
- title?: string;
110
- };
111
- location: {
112
- latitude: number;
113
- longitude: number;
114
- title?: string;
115
- content?: string;
116
- };
117
- share: {
118
- url: string;
119
- title: string;
120
- content?: string;
121
- image?: string;
122
- };
123
- reply: {
124
- message_id: string;
125
- };
126
- node: {
127
- user_id: string;
128
- time?: number;
129
- user_name?: string;
130
- message: SegmentElem[];
131
- };
132
- forward: {
133
- nodes: SegmentElem<"node">[];
134
- };
135
- }
136
- type SegmentElem<K extends keyof SegmentMap = keyof SegmentMap> = {
137
- type: K;
138
- data: SegmentMap[K];
139
- };
140
70
  interface Config {
141
71
  heartbeat?: number;
142
72
  access_token?: string;
@@ -263,11 +193,14 @@ export declare namespace V12 {
263
193
  user_name: string;
264
194
  }
265
195
  interface Segment {
196
+ type: string;
197
+ data: Dict;
266
198
  }
199
+ type Sendable = string | Segment | (string | Segment)[];
267
200
  interface Message {
201
+ message: Sendable;
268
202
  }
269
- interface MessageElement extends Dict {
270
- type: string;
203
+ interface Message {
271
204
  }
272
205
  interface MessageRet {
273
206
  message_id: string;
@@ -394,6 +394,9 @@ class V12 extends service_1.Service {
394
394
  user_id: `${this.oneBot.uin}`,
395
395
  },
396
396
  });
397
+ if (payload.message && payload.type === "message") {
398
+ payload.message = this.adapter.transformMessage(this.oneBot.uin, "V12", payload.message);
399
+ }
397
400
  if (!this.filterFn(payload))
398
401
  return;
399
402
  this.emit("dispatch", payload);
@@ -442,13 +445,7 @@ class V12 extends service_1.Service {
442
445
  }
443
446
  params[k] = this.adapter.fromCqcode("V12", params[k]);
444
447
  }
445
- else {
446
- if (params[k][0].type == "music" && params[k][0]?.data?.type) {
447
- params[k][0].data.platform = params[k][0].data.type;
448
- delete params[k][0].data.type;
449
- }
450
- params[k] = this.adapter.fromSegment("V12", params[k]);
451
- }
448
+ params[k] = this.adapter.fromSegment("V12", params[k]);
452
449
  }
453
450
  args.push(params[k]);
454
451
  }
@@ -622,6 +619,7 @@ class V12 extends service_1.Service {
622
619
  const headers = {
623
620
  "User-Agent": `OneBot/12 (${this.oneBot.platform}) onebots/${utils_1.version}`,
624
621
  };
622
+ console.log(config);
625
623
  if (config.access_token)
626
624
  headers.Authorization = "Bearer " + config.access_token;
627
625
  const ws = new ws_1.WebSocket(remoteUrl, ["12.OneBots"], { headers });
@@ -655,7 +653,7 @@ class V12 extends service_1.Service {
655
653
  try {
656
654
  data = JSON.parse(String(msg));
657
655
  let ret;
658
- if (data.action.startsWith(".handle_quick_operation")) {
656
+ if (data.action?.startsWith(".handle_quick_operation")) {
659
657
  const event = data.params.context, res = data.params.operation;
660
658
  this._quickOperate(event, res);
661
659
  ret = JSON.stringify({
@@ -707,7 +705,6 @@ class V12 extends service_1.Service {
707
705
  }
708
706
  exports.V12 = V12;
709
707
  (function (V12) {
710
- const fileTypes = ["image", "file", "record", "video", "flash"];
711
708
  V12.defaultConfig = {
712
709
  heartbeat: 3,
713
710
  access_token: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.4.59",
3
+ "version": "0.4.61",
4
4
  "description": "基于icqq的多例oneBot实现",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -28,14 +28,17 @@
28
28
  "keywords": [
29
29
  "onebot",
30
30
  "icqq",
31
+ "qq",
32
+ "wechat",
33
+ "dingtalk",
31
34
  "cq-http"
32
35
  ],
33
36
  "author": "凉菜",
34
37
  "license": "MIT",
35
38
  "bugs": {
36
- "url": "https://github.com/liucl-cn/onebots/issues"
39
+ "url": "https://github.com/lc-cn/onebots/issues"
37
40
  },
38
- "homepage": "https://github.com/liucl-cn/onebots#readme",
41
+ "homepage": "https://github.com/lc-cn/onebots#readme",
39
42
  "devDependencies": {
40
43
  "@types/koa": "^2.13.4",
41
44
  "@types/koa__router": "^8.0.11",