onebots 0.1.9 → 0.1.11
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/service/V12/action/friend.d.ts +2 -2
- package/lib/service/V12/action/friend.js +1 -1
- package/lib/service/V12/action/group.d.ts +2 -2
- package/lib/service/V12/action/group.js +1 -1
- package/lib/service/V12/action/guild.d.ts +7 -2
- package/lib/service/V12/action/guild.js +6 -0
- package/lib/service/V12/action/utils.d.ts +1 -1
- package/lib/service/V12/action/utils.js +15 -8
- package/lib/service/V12/index.d.ts +9 -6
- package/package.json +1 -1
|
@@ -11,8 +11,8 @@ export declare class FriendAction {
|
|
|
11
11
|
/**
|
|
12
12
|
* 发送私聊消息
|
|
13
13
|
* @param user_id {number} 用户id
|
|
14
|
-
* @param message {import('icqq').Sendable}
|
|
14
|
+
* @param message {import('icqq/lib/service').Sendable} 消息
|
|
15
15
|
* @param message_id {string} 引用的消息ID
|
|
16
16
|
*/
|
|
17
|
-
sendPrivateMsg(this: V12, user_id: number, message: V12.
|
|
17
|
+
sendPrivateMsg(this: V12, user_id: number, message: V12.Sendable, message_id?: string): Promise<import("icqq").MessageRet>;
|
|
18
18
|
}
|
|
@@ -12,7 +12,7 @@ class FriendAction {
|
|
|
12
12
|
/**
|
|
13
13
|
* 发送私聊消息
|
|
14
14
|
* @param user_id {number} 用户id
|
|
15
|
-
* @param message {import('icqq').Sendable}
|
|
15
|
+
* @param message {import('icqq/lib/service').Sendable} 消息
|
|
16
16
|
* @param message_id {string} 引用的消息ID
|
|
17
17
|
*/
|
|
18
18
|
async sendPrivateMsg(user_id, message, message_id) {
|
|
@@ -3,10 +3,10 @@ export declare class GroupAction {
|
|
|
3
3
|
/**
|
|
4
4
|
* 发送群聊消息
|
|
5
5
|
* @param group_id {number} 群id
|
|
6
|
-
* @param message {import('icqq').Sendable} 消息
|
|
6
|
+
* @param message {import('icqq/lib/service').Sendable} 消息
|
|
7
7
|
* @param message_id {string} 引用的消息ID
|
|
8
8
|
*/
|
|
9
|
-
sendGroupMsg(this: V12, group_id: number, message: V12.
|
|
9
|
+
sendGroupMsg(this: V12, group_id: number, message: V12.Sendable, message_id?: string): Promise<import("icqq").MessageRet>;
|
|
10
10
|
/**
|
|
11
11
|
* 群组踢人
|
|
12
12
|
* @param group_id {number} 群id
|
|
@@ -6,7 +6,7 @@ class GroupAction {
|
|
|
6
6
|
/**
|
|
7
7
|
* 发送群聊消息
|
|
8
8
|
* @param group_id {number} 群id
|
|
9
|
-
* @param message {import('icqq').Sendable} 消息
|
|
9
|
+
* @param message {import('icqq/lib/service').Sendable} 消息
|
|
10
10
|
* @param message_id {string} 引用的消息ID
|
|
11
11
|
*/
|
|
12
12
|
async sendGroupMsg(group_id, message, message_id) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { V12 } from "../../../service/V12";
|
|
2
|
-
import SegmentElem = V12.SegmentElem;
|
|
3
2
|
export declare class GuildAction {
|
|
4
3
|
getGuildList(this: V12): {
|
|
5
4
|
guild_id: string;
|
|
@@ -12,7 +11,13 @@ export declare class GuildAction {
|
|
|
12
11
|
channel_type: import("icqq/lib/channel").ChannelType;
|
|
13
12
|
}[];
|
|
14
13
|
getGuildMemberList(this: V12, guild_id: string): never[] | Promise<import("icqq/lib/guild").GuildMember[]>;
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 发送群聊消息
|
|
16
|
+
* @param guild_id {number} 频道id
|
|
17
|
+
* @param channel_id {string} 子频道id
|
|
18
|
+
* @param message {import('icqq/lib/service').Sendable} 消息
|
|
19
|
+
*/
|
|
20
|
+
sendGuildMsg(this: V12, guild_id: string, channel_id: string, message: V12.Sendable): Promise<{
|
|
16
21
|
seq: number;
|
|
17
22
|
rand: number;
|
|
18
23
|
time: number;
|
|
@@ -12,6 +12,12 @@ class GuildAction {
|
|
|
12
12
|
getGuildMemberList(guild_id) {
|
|
13
13
|
return this.client.getGuildMemberList(guild_id);
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* 发送群聊消息
|
|
17
|
+
* @param guild_id {number} 频道id
|
|
18
|
+
* @param channel_id {string} 子频道id
|
|
19
|
+
* @param message {import('icqq/lib/service').Sendable} 消息
|
|
20
|
+
*/
|
|
15
21
|
async sendGuildMsg(guild_id, channel_id, message) {
|
|
16
22
|
const { element } = await utils_1.processMessage.apply(this.client, [message]);
|
|
17
23
|
if (!element.length)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client, MessageElem } from "icqq";
|
|
2
2
|
import { V12 } from "../../../service/V12";
|
|
3
3
|
export declare function processMusic(this: Client, target_type: 'group' | 'friend', target_id: number, element: any): Promise<any>;
|
|
4
|
-
export declare function processMessage(this: Client, message: V12.
|
|
4
|
+
export declare function processMessage(this: Client, message: V12.Sendable, quote_id?: string): Promise<{
|
|
5
5
|
element: MessageElem[];
|
|
6
6
|
quote_id?: string;
|
|
7
7
|
}>;
|
|
@@ -15,19 +15,26 @@ async function processMusic(target_type, target_id, element) {
|
|
|
15
15
|
}
|
|
16
16
|
exports.processMusic = processMusic;
|
|
17
17
|
async function processMessage(message, quote_id) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
let segments = [].concat(message).map(m => {
|
|
19
|
+
if (typeof m === 'string')
|
|
20
|
+
return { type: 'text', data: { text: m } };
|
|
21
|
+
return m;
|
|
22
|
+
});
|
|
23
|
+
const forward = segments.find(e => e.type === 'forward');
|
|
24
|
+
if (forward)
|
|
25
|
+
(0, utils_1.remove)(segments, forward);
|
|
26
|
+
let quote = segments.find(e => e.type === 'reply');
|
|
22
27
|
if (quote)
|
|
23
|
-
(0, utils_1.remove)(
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
(0, utils_1.remove)(segments, quote);
|
|
29
|
+
// 直接发node?不允许,你用forward作为载体吧
|
|
30
|
+
segments = segments.filter(n => n.type !== 'node');
|
|
31
|
+
const element = V12_1.V12.fromSegment(segments);
|
|
32
|
+
if (forward)
|
|
26
33
|
element.unshift(
|
|
27
34
|
// 构造抓发消息
|
|
28
35
|
await this.makeForwardMsg(await Promise.all(
|
|
29
36
|
// 处理转发消息段
|
|
30
|
-
|
|
37
|
+
forward.data.nodes.filter(n => n.type === 'node').map(async (forwardNode) => {
|
|
31
38
|
return {
|
|
32
39
|
// 转发套转发处理
|
|
33
40
|
message: (await processMessage.apply(this, [V12_1.V12.fromSegment(forwardNode.data.message)])).element,
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Client, EventMap, MessageElem, Sendable } from "icqq";
|
|
3
|
+
import { Client, EventMap, MessageElem, Sendable as IcqqCanSend } from "icqq";
|
|
4
4
|
import { Config } from './config';
|
|
5
5
|
import { OneBot } from "../../onebot";
|
|
6
6
|
import { Action } from "./action";
|
|
7
7
|
import { EventEmitter } from "events";
|
|
8
8
|
import { Logger } from "log4js";
|
|
9
9
|
import { WebSocket, WebSocketServer } from "ws";
|
|
10
|
-
import Payload = V12.Payload;
|
|
11
10
|
export declare class V12 extends EventEmitter implements OneBot.Base {
|
|
12
11
|
oneBot: OneBot<'V12'>;
|
|
13
12
|
client: Client;
|
|
@@ -22,8 +21,8 @@ export declare class V12 extends EventEmitter implements OneBot.Base {
|
|
|
22
21
|
wsr: Set<WebSocket>;
|
|
23
22
|
private db;
|
|
24
23
|
constructor(oneBot: OneBot<'V12'>, client: Client, config: V12.Config);
|
|
25
|
-
get history(): Payload<keyof Action>[];
|
|
26
|
-
set history(value: Payload<keyof Action>[]);
|
|
24
|
+
get history(): V12.Payload<keyof Action>[];
|
|
25
|
+
set history(value: V12.Payload<keyof Action>[]);
|
|
27
26
|
start(path?: string): void;
|
|
28
27
|
private startHttp;
|
|
29
28
|
private startWebhook;
|
|
@@ -55,8 +54,9 @@ export declare class V12 extends EventEmitter implements OneBot.Base {
|
|
|
55
54
|
protected _webSocketHandler(ws: WebSocket): void;
|
|
56
55
|
}
|
|
57
56
|
export declare namespace V12 {
|
|
58
|
-
|
|
59
|
-
function
|
|
57
|
+
type Sendable = string | SegmentElem | (string | SegmentElem)[];
|
|
58
|
+
function fromSegment(msgList: Sendable[]): MessageElem[];
|
|
59
|
+
function toSegment(msgList: IcqqCanSend): SegmentElem<keyof SegmentMap>[];
|
|
60
60
|
interface SegmentMap {
|
|
61
61
|
face: {
|
|
62
62
|
id: number;
|
|
@@ -81,6 +81,9 @@ export declare namespace V12 {
|
|
|
81
81
|
file: {
|
|
82
82
|
file_id: string;
|
|
83
83
|
};
|
|
84
|
+
forward: {
|
|
85
|
+
nodes: SegmentElem<'node'>[];
|
|
86
|
+
};
|
|
84
87
|
music: {
|
|
85
88
|
type: "163" | 'qq' | 'xm' | 'custom';
|
|
86
89
|
id?: string;
|