mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d3514a737 | ||
|
|
69d9acafe7 |
@@ -860,17 +860,15 @@ export default {
|
|||||||
// 过滤出属于该平台的路由,并保持顺序
|
// 过滤出属于该平台的路由,并保持顺序
|
||||||
const routes = [];
|
const routes = [];
|
||||||
for (const [umop, confId] of Object.entries(routingTable)) {
|
for (const [umop, confId] of Object.entries(routingTable)) {
|
||||||
if (this.isUmopMatchPlatform(umop, platformId)) {
|
const parsedUmop = this.parseUmop(umop);
|
||||||
const parts = umop.split(':');
|
if (this.isParsedUmopMatchPlatform(parsedUmop, platformId)) {
|
||||||
if (parts.length === 3) {
|
routes.push({
|
||||||
routes.push({
|
umop: umop,
|
||||||
umop: umop,
|
originalUmop: umop, // 保存原始 UMOP 用于更新时查找
|
||||||
originalUmop: umop, // 保存原始 UMOP 用于更新时查找
|
messageType: parsedUmop.messageType || '*',
|
||||||
messageType: parts[1] === '' || parts[1] === '*' ? '*' : parts[1],
|
sessionId: parsedUmop.sessionId || '*',
|
||||||
sessionId: parts[2] === '' || parts[2] === '*' ? '*' : parts[2],
|
configId: confId
|
||||||
configId: confId
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -992,11 +990,29 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
isUmopMatchPlatform(umop, platformId) {
|
isUmopMatchPlatform(umop, platformId) {
|
||||||
if (!umop) return false;
|
const parsedUmop = this.parseUmop(umop);
|
||||||
const parts = umop.split(':');
|
return this.isParsedUmopMatchPlatform(parsedUmop, platformId);
|
||||||
if (parts.length !== 3) return false;
|
},
|
||||||
const platform = parts[0];
|
|
||||||
return platform === platformId || platform === '' || platform === '*';
|
isParsedUmopMatchPlatform(parsedUmop, platformId) {
|
||||||
|
if (!parsedUmop) return false;
|
||||||
|
return parsedUmop.platform === platformId || parsedUmop.platform === '' || parsedUmop.platform === '*';
|
||||||
|
},
|
||||||
|
|
||||||
|
parseUmop(umop) {
|
||||||
|
if (!umop) return null;
|
||||||
|
|
||||||
|
const firstSeparatorIndex = umop.indexOf(':');
|
||||||
|
if (firstSeparatorIndex === -1) return null;
|
||||||
|
|
||||||
|
const secondSeparatorIndex = umop.indexOf(':', firstSeparatorIndex + 1);
|
||||||
|
if (secondSeparatorIndex === -1) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
platform: umop.slice(0, firstSeparatorIndex),
|
||||||
|
messageType: umop.slice(firstSeparatorIndex + 1, secondSeparatorIndex),
|
||||||
|
sessionId: umop.slice(secondSeparatorIndex + 1)
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取消息类型标签
|
// 获取消息类型标签
|
||||||
|
|||||||
Reference in New Issue
Block a user