@alemonjs/onebot 2.1.0-alpha.6 → 2.1.0-alpha.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/index.js +1 -5
- package/lib/sdk/wss.js +5 -11
- package/package.json +4 -1
package/lib/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var index = () => {
|
|
|
20
20
|
reverse_port: config?.reverse_port ?? 17158
|
|
21
21
|
});
|
|
22
22
|
client.connect();
|
|
23
|
-
const url = `ws://127.0.0.1:${process.env?.port ||
|
|
23
|
+
const url = `ws://127.0.0.1:${process.env?.port || 17117}`;
|
|
24
24
|
const cbp = cbpPlatform(url);
|
|
25
25
|
const createUserAvatar = (id) => {
|
|
26
26
|
return `https://q1.qlogo.cn/g?b=qq&s=0&nk=${id}`;
|
|
@@ -91,10 +91,6 @@ var index = () => {
|
|
|
91
91
|
};
|
|
92
92
|
cbp.send(e);
|
|
93
93
|
});
|
|
94
|
-
// 错误处理
|
|
95
|
-
client.on('ERROR', event => {
|
|
96
|
-
logger.error(event);
|
|
97
|
-
});
|
|
98
94
|
/**
|
|
99
95
|
* @param val
|
|
100
96
|
* @returns
|
package/lib/sdk/wss.js
CHANGED
|
@@ -51,8 +51,7 @@ class OneBotClient extends OneBotAPI {
|
|
|
51
51
|
try {
|
|
52
52
|
const event = JSON.parse(data.toString());
|
|
53
53
|
if (!event) {
|
|
54
|
-
|
|
55
|
-
this.#events['ERROR'](event);
|
|
54
|
+
logger.error('[OneBot] WebSocket message is empty');
|
|
56
55
|
return;
|
|
57
56
|
}
|
|
58
57
|
else if (event?.post_type == 'meta_event') {
|
|
@@ -102,16 +101,11 @@ class OneBotClient extends OneBotAPI {
|
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
catch (err) {
|
|
105
|
-
|
|
106
|
-
this.#events['ERROR'](err);
|
|
104
|
+
logger.error('[OneBot] WebSocket error: ', err);
|
|
107
105
|
}
|
|
108
106
|
};
|
|
109
107
|
const onClose = (code, reason) => {
|
|
110
|
-
|
|
111
|
-
this.#events['ERROR']({
|
|
112
|
-
de: code,
|
|
113
|
-
reason: reason.toString('utf8')
|
|
114
|
-
});
|
|
108
|
+
logger.error(`[OneBot] WebSocket closed: ${code} - ${reason.toString('utf8')}`);
|
|
115
109
|
};
|
|
116
110
|
if (!this.ws) {
|
|
117
111
|
if (reverse_enable) {
|
|
@@ -123,14 +117,14 @@ class OneBotClient extends OneBotAPI {
|
|
|
123
117
|
this.ws.on('message', onMessage);
|
|
124
118
|
// close
|
|
125
119
|
this.ws.on('close', onClose);
|
|
126
|
-
|
|
120
|
+
logger.info(`[OneBot] connected: ws://127.0.0.1:${reverse_port}`);
|
|
127
121
|
});
|
|
128
122
|
}
|
|
129
123
|
else {
|
|
130
124
|
// forward_open
|
|
131
125
|
this.ws = new WebSocket(url, c);
|
|
132
126
|
this.ws.on('open', () => {
|
|
133
|
-
|
|
127
|
+
logger.info(`[OneBot] connected: ${url}`);
|
|
134
128
|
});
|
|
135
129
|
// message
|
|
136
130
|
this.ws.on('message', onMessage);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/onebot",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.7",
|
|
4
4
|
"description": "onebot v11",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"ws": "^8.18.1"
|
|
25
25
|
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"alemonjs": "^2.1.0-alpha.15"
|
|
28
|
+
},
|
|
26
29
|
"alemonjs": {
|
|
27
30
|
"desktop": {
|
|
28
31
|
"platform": [
|