jsir 2.5.6 → 2.5.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/cmd/oaa.js +4 -2
- package/deps/room.js +1 -1
- package/deps/server.js +4 -2
- package/deps/util.js +9 -4
- package/package.json +1 -1
package/cmd/oaa.js
CHANGED
|
@@ -714,7 +714,9 @@ async function dealStar(text) {
|
|
|
714
714
|
if (_cmdMap.hasOwnProperty(items[0])) {
|
|
715
715
|
rows.push(...await dealStarCmd([], _cmdMap[items[0]], items.slice(1).join(' ')))
|
|
716
716
|
} else if (items[0].indexOf("/") !== -1) {
|
|
717
|
-
|
|
717
|
+
for (let cmd of filterCmd(items[0])) {
|
|
718
|
+
dealStarCmd(rows, cmd, items.slice(1).join(" "))
|
|
719
|
+
}
|
|
718
720
|
} else {
|
|
719
721
|
try {
|
|
720
722
|
let result = await evalText(`return ${items[0]}`)
|
|
@@ -739,7 +741,7 @@ function dealStarGlobal(items, text) {
|
|
|
739
741
|
prefix = trim(items[0].substring(0, index + 1))
|
|
740
742
|
text = trim(text.substring(index + 1))
|
|
741
743
|
}
|
|
742
|
-
for (let cmd of filterCmd(prefix + '^i
|
|
744
|
+
for (let cmd of filterCmd(prefix + '^i[^a-zA-Z]')) {
|
|
743
745
|
dealStarCmd(rows, cmd, text)
|
|
744
746
|
}
|
|
745
747
|
return rows;
|
package/deps/room.js
CHANGED
|
@@ -249,7 +249,7 @@ async function _syncSetting(room) {
|
|
|
249
249
|
setting.rooms = [setting.selfRoom, ...rooms]
|
|
250
250
|
.map(room => {
|
|
251
251
|
room.active = Date.now() - (room.lastUpdateTime || 0) <= setting.roomHeartbeatExpire;
|
|
252
|
-
Object.entries(room.jsirs).forEach(([key, jsir]) =>
|
|
252
|
+
Object.entries(room.jsirs || {}).forEach(([key, jsir]) =>
|
|
253
253
|
jsir.active = Date.now() - (jsir.lastUpdateTime || 0) <= setting.roomHeartbeatExpire)
|
|
254
254
|
return room;
|
|
255
255
|
});
|
package/deps/server.js
CHANGED
|
@@ -36,7 +36,7 @@ function createSign() {
|
|
|
36
36
|
async function process(routeKey, req, res, params) {
|
|
37
37
|
let router = routes[routeKey]
|
|
38
38
|
if (router) {
|
|
39
|
-
if ("get /" !== routeKey && !router.isApi
|
|
39
|
+
if ("get /" !== routeKey && !router.isApi) {
|
|
40
40
|
// 如果不是api接口,则校验签名
|
|
41
41
|
// 取header里的sign字段
|
|
42
42
|
const sign = req.headers['sign'];
|
|
@@ -143,7 +143,9 @@ async function startServer() {
|
|
|
143
143
|
*/
|
|
144
144
|
function setRoute(method, url, fn, isApi = false, handler = jsonHandle) {
|
|
145
145
|
startServer();
|
|
146
|
-
|
|
146
|
+
if (apiReg.test(url)) {
|
|
147
|
+
isApi = true;
|
|
148
|
+
}
|
|
147
149
|
const routeKey = `${method.toLowerCase()} ${url}`;
|
|
148
150
|
if (handler) {
|
|
149
151
|
routes[routeKey] = {
|
package/deps/util.js
CHANGED
|
@@ -26,6 +26,7 @@ let tempDir;
|
|
|
26
26
|
let configDir;
|
|
27
27
|
let roomsDir;
|
|
28
28
|
let dataDir;
|
|
29
|
+
let console = global.console
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
function isRunningInBackground() {
|
|
@@ -286,7 +287,7 @@ function createConsole(uniqueName) {
|
|
|
286
287
|
return result;
|
|
287
288
|
}
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
console = createConsole();
|
|
290
291
|
// fix console done
|
|
291
292
|
|
|
292
293
|
|
|
@@ -1405,9 +1406,13 @@ function cleanFile(path, maxChars = 9 * 1024 * 1024) {
|
|
|
1405
1406
|
return;
|
|
1406
1407
|
}
|
|
1407
1408
|
await fileLock(path, async () => {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1409
|
+
const bakFile = `${path}.bak`;
|
|
1410
|
+
// 备份日志
|
|
1411
|
+
try {
|
|
1412
|
+
await fp.rename(path, bakFile);
|
|
1413
|
+
} catch (e) {
|
|
1414
|
+
console.error(`Failed to rename ${path} -> ${bakFile}`, e);
|
|
1415
|
+
}
|
|
1411
1416
|
}, false)
|
|
1412
1417
|
}, path)
|
|
1413
1418
|
}
|