@karinjs/adapter-qqbot 1.2.6 → 1.2.7
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/core/api.js +2 -2
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.js +14 -6
- package/package.json +1 -1
package/lib/core/api.js
CHANGED
|
@@ -41,7 +41,7 @@ export class QQBotApi extends EventEmitter {
|
|
|
41
41
|
this.wssUrl = '';
|
|
42
42
|
this.heartbeat = { op: 1, d: null, session_id: '' };
|
|
43
43
|
this.heartbeat_interval = 0;
|
|
44
|
-
// 后续处理 重启后重新建立历史会话
|
|
44
|
+
// todo: 后续处理 重启后重新建立历史会话
|
|
45
45
|
}
|
|
46
46
|
logger(level, ...args) {
|
|
47
47
|
logger.bot(level, this.appId, ...args);
|
|
@@ -112,7 +112,7 @@ export class QQBotApi extends EventEmitter {
|
|
|
112
112
|
shard: [0, 1],
|
|
113
113
|
properties: {
|
|
114
114
|
$os: 'Linux',
|
|
115
|
-
$browser: '
|
|
115
|
+
$browser: '@karinjs/adapter-qqbot',
|
|
116
116
|
$device: 'karin',
|
|
117
117
|
},
|
|
118
118
|
},
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QQBotApi } from './api.js';
|
|
2
2
|
import { PathType, C2CMessageCreateEvent, GroupAtMessageCreateEvent } from '../types/index.js';
|
|
3
3
|
import { GlobalCfgType, AccountCfgType } from '../utils/index.js';
|
|
4
|
-
import { Contact, LoggerLevel, ReplyReturn, KarinAdapter, KarinElement } from 'node-karin';
|
|
4
|
+
import { Contact, LoggerLevel, ReplyReturn, KarinMessage, KarinAdapter, KarinElement } from 'node-karin';
|
|
5
5
|
/**
|
|
6
6
|
* - QQBot适配器
|
|
7
7
|
*/
|
|
@@ -15,7 +15,7 @@ export declare class AdapterQQBot implements KarinAdapter {
|
|
|
15
15
|
markdown: GlobalCfgType;
|
|
16
16
|
constructor(config: AccountCfgType);
|
|
17
17
|
init(): Promise<void>;
|
|
18
|
-
_sendNsg(elements: Array<KarinElement>, type: PathType, openid: string, message_id?: string): Promise<ReplyReturn>;
|
|
18
|
+
_sendNsg(e: KarinMessage, elements: Array<KarinElement>, type: PathType, openid: string, message_id?: string): Promise<ReplyReturn>;
|
|
19
19
|
get self_id(): string;
|
|
20
20
|
logger(level: LoggerLevel, ...args: any[]): void;
|
|
21
21
|
GetVersion(): Promise<{
|
package/lib/core/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QQBotApi } from './api.js';
|
|
2
2
|
import { markdownTemplate, markdownRaw } from './markdown.js';
|
|
3
3
|
import { common, common as Common, config as Config, } from '../utils/index.js';
|
|
4
|
-
import { logger, karin, segment, KarinMessage, } from 'node-karin';
|
|
4
|
+
import { logger, karin, segment, KarinMessage, button, } from 'node-karin';
|
|
5
5
|
/**
|
|
6
6
|
* - QQBot适配器
|
|
7
7
|
*/
|
|
@@ -25,12 +25,20 @@ export class AdapterQQBot {
|
|
|
25
25
|
switch (this.markdown.sendMode) {
|
|
26
26
|
/** 原生 */
|
|
27
27
|
case 1: {
|
|
28
|
-
this._sendNsg = async (elements, type, openid, message_id) =>
|
|
28
|
+
this._sendNsg = async (e, elements, type, openid, message_id) => {
|
|
29
|
+
const list = await button(e.msg);
|
|
30
|
+
elements.push(...list);
|
|
31
|
+
return await markdownRaw({ bot: this, data: elements, type, openid, message_id });
|
|
32
|
+
};
|
|
29
33
|
return;
|
|
30
34
|
}
|
|
31
35
|
/** 旧图文模板 */
|
|
32
36
|
case 3: {
|
|
33
|
-
this._sendNsg = async (elements, type, openid, message_id) =>
|
|
37
|
+
this._sendNsg = async (e, elements, type, openid, message_id) => {
|
|
38
|
+
const list = await button(e.msg);
|
|
39
|
+
elements.push(...list);
|
|
40
|
+
return await markdownTemplate({ bot: this, data: elements, type, openid, message_id });
|
|
41
|
+
};
|
|
34
42
|
return;
|
|
35
43
|
}
|
|
36
44
|
/** 纯文 现已不能申请 */
|
|
@@ -78,7 +86,7 @@ export class AdapterQQBot {
|
|
|
78
86
|
};
|
|
79
87
|
const e = new KarinMessage(message);
|
|
80
88
|
e.bot = this;
|
|
81
|
-
e.replyCallback = async (elements) => await this._sendNsg(elements, "groups" /* PathType.Groups */, e.contact.peer, e.message_id);
|
|
89
|
+
e.replyCallback = async (elements) => await this._sendNsg(e, elements, "groups" /* PathType.Groups */, e.contact.peer, e.message_id);
|
|
82
90
|
karin.emit('adapter.message', e);
|
|
83
91
|
});
|
|
84
92
|
this.super.on("C2C_MESSAGE_CREATE" /* QQBotEventType.C2C_MESSAGE_CREATE */, (data) => {
|
|
@@ -111,7 +119,7 @@ export class AdapterQQBot {
|
|
|
111
119
|
};
|
|
112
120
|
const e = new KarinMessage(message);
|
|
113
121
|
e.bot = this;
|
|
114
|
-
e.replyCallback = async (elements) => await this._sendNsg(elements, "users" /* PathType.Friends */, e.contact.peer, e.message_id);
|
|
122
|
+
e.replyCallback = async (elements) => await this._sendNsg(e, elements, "users" /* PathType.Friends */, e.contact.peer, e.message_id);
|
|
115
123
|
karin.emit('adapter.message', e);
|
|
116
124
|
});
|
|
117
125
|
/** 等待建立连接 注册Bot */
|
|
@@ -124,7 +132,7 @@ export class AdapterQQBot {
|
|
|
124
132
|
this.adapter.index = index;
|
|
125
133
|
});
|
|
126
134
|
}
|
|
127
|
-
async _sendNsg(elements, type, openid, message_id) {
|
|
135
|
+
async _sendNsg(e, elements, type, openid, message_id) {
|
|
128
136
|
return await this.KarinConvertAdapter(elements, type, openid, message_id);
|
|
129
137
|
}
|
|
130
138
|
get self_id() {
|