alemonjs 1.0.52 → 1.0.53
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/ip.js +3 -2
- package/lib/define/main.js +7 -3
- package/lib/koa/img.js +7 -4
- package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +2 -2
- package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +2 -2
- package/lib/villa/sdk/client.js +6 -4
- package/package.json +1 -1
- package/types/core/ip.d.ts +2 -1
- package/types/koa/types.d.ts +5 -0
package/lib/core/ip.js
CHANGED
|
@@ -4,11 +4,12 @@ let myIp;
|
|
|
4
4
|
* 得到本机IP地址
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export async function getIP() {
|
|
7
|
+
export async function getIP(options = {}) {
|
|
8
8
|
if (myIp)
|
|
9
9
|
return myIp;
|
|
10
10
|
return await publicIp({
|
|
11
|
-
|
|
11
|
+
onlyHttps: true,
|
|
12
|
+
...options
|
|
12
13
|
}).then(ip => {
|
|
13
14
|
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(ip))
|
|
14
15
|
myIp = ip;
|
package/lib/define/main.js
CHANGED
|
@@ -4,7 +4,7 @@ import { nodeScripts } from './child_process.js';
|
|
|
4
4
|
import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
|
|
5
5
|
import { ClientNTQQ } from '../ntqq/sdk/index.js';
|
|
6
6
|
import { command } from './command.js';
|
|
7
|
-
import { createApp, setLanchConfig, loadInit, appsInit, setAppProCoinfg, startChrom } from '../core/index.js';
|
|
7
|
+
import { createApp, setLanchConfig, loadInit, appsInit, setAppProCoinfg, startChrom, getIP } from '../core/index.js';
|
|
8
8
|
import { getPupPath, setBotConfigByKey, getBotConfigByKey } from '../config/index.js';
|
|
9
9
|
import { createWeb } from '../koa/index.js';
|
|
10
10
|
import { autoClearImages } from '../koa/img.js';
|
|
@@ -159,8 +159,12 @@ export async function defineAlemonConfig(Options) {
|
|
|
159
159
|
if (Options?.server?.state != false) {
|
|
160
160
|
// 创建server端
|
|
161
161
|
createWeb(Options?.server);
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
if (Options?.server?.clear != false) {
|
|
163
|
+
// 定时清除
|
|
164
|
+
autoClearImages();
|
|
165
|
+
}
|
|
166
|
+
// 缓存ip
|
|
167
|
+
getIP();
|
|
164
168
|
}
|
|
165
169
|
/**
|
|
166
170
|
* ***********
|
package/lib/koa/img.js
CHANGED
|
@@ -56,10 +56,13 @@ export async function setLocalImg(img) {
|
|
|
56
56
|
const imgSize = getServerConfig('imgSize');
|
|
57
57
|
const port = getServerConfig('port');
|
|
58
58
|
const http = getServerConfig('http');
|
|
59
|
-
let ip =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
let ip = getServerConfig('ip');
|
|
60
|
+
if (ip == 'localhost') {
|
|
61
|
+
const ipp = await getIP();
|
|
62
|
+
if (ipp)
|
|
63
|
+
ip = ipp;
|
|
64
|
+
}
|
|
65
|
+
console.log('测试1');
|
|
63
66
|
// 生成文件名
|
|
64
67
|
const filename = `${Math.floor(Math.random() * imgSize)}.${(await fileTypeFromBuffer(img))?.ext}`;
|
|
65
68
|
// 文件路径
|
|
@@ -56,7 +56,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
56
56
|
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
57
57
|
if (!url)
|
|
58
58
|
return false;
|
|
59
|
-
return await ClientNTQQ.postMessageByUser(event.author.user_openid, `${cont} `,
|
|
59
|
+
return await ClientNTQQ.postMessageByUser(event.author.user_openid, `${cont} `, event.id).catch(everyoneError);
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
62
|
console.error(err);
|
|
@@ -86,7 +86,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
86
86
|
return await ClientNTQQ.postFilesByUsers(event.author.user_openid, url).catch(everyoneError);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
return await ClientNTQQ.postMessageByUser(event.author.user_openid, content,
|
|
89
|
+
return await ClientNTQQ.postMessageByUser(event.author.user_openid, content, event.id).catch(everyoneError);
|
|
90
90
|
};
|
|
91
91
|
e.replyCard = async (arr) => {
|
|
92
92
|
for (const item of arr) {
|
|
@@ -62,7 +62,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
62
62
|
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
63
63
|
if (!url)
|
|
64
64
|
return false;
|
|
65
|
-
return await ClientNTQQ.postMessageByGroup(event.group_id, `${cont} `,
|
|
65
|
+
return await ClientNTQQ.postMessageByGroup(event.group_id, `${cont} `, event.id).catch(everyoneError);
|
|
66
66
|
}
|
|
67
67
|
catch (err) {
|
|
68
68
|
console.error(err);
|
|
@@ -92,7 +92,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
92
92
|
return await ClientNTQQ.postFilesByGroup(event.group_id, url).catch(everyoneError);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
return await ClientNTQQ.postMessageByGroup(event.group_id, content,
|
|
95
|
+
return await ClientNTQQ.postMessageByGroup(event.group_id, content, event.id).catch(everyoneError);
|
|
96
96
|
};
|
|
97
97
|
e.replyCard = async (arr) => {
|
|
98
98
|
for (const item of arr) {
|
package/lib/villa/sdk/client.js
CHANGED
|
@@ -109,10 +109,12 @@ export function createClient({ bot_id, bot_secret, callback_url = '/api/mys/call
|
|
|
109
109
|
await logFnc(port);
|
|
110
110
|
}
|
|
111
111
|
// 获取ip4
|
|
112
|
-
let ip =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
let ip = getServerConfig('ip');
|
|
113
|
+
if (ip == 'localhost') {
|
|
114
|
+
const ipp = await getIP();
|
|
115
|
+
if (ipp)
|
|
116
|
+
ip = ipp;
|
|
117
|
+
}
|
|
116
118
|
console.info('villa open', `http://${ip}:${port}${callback_url}`);
|
|
117
119
|
if (!ip)
|
|
118
120
|
console.error('vllia no public ip');
|
package/package.json
CHANGED
package/types/core/ip.d.ts
CHANGED