fix(security): 硬编码特殊账号改为可配置数组 NAPCAT_SPECIAL_PEER_UINS
- onebot/api/msg.ts(3处)与 core/helper/log.ts(1处)原先写死两个特定 peerUin, 用于: 回复消息直接返回缓存的 createReplyData / 走合并视频URL 特殊通道 / 回复元素跳过递归解析 / 临时会话兜底 group_id。 - 改为环境变量 NAPCAT_SPECIAL_PEER_UINS(逗号分隔, 校验纯数字)读取, 默认为空数组 = 不做任何特殊处理。 - 如需恢复旧行为: NAPCAT_SPECIAL_PEER_UINS='<原两个号码>' 即可。 回归注意: 默认关闭特殊通道后, 对这两类会话的合并转发视频URL获取与回复 缓存直返行为会走通用分支, 建议内部测试确认无回归后按需配置环境变量。
This commit is contained in:
1 parent
030ecb206c
commit
76520c6157
2 files changed
+19
-4
No files matched your search
@@ -336,9 +336,16 @@ function textElementToText (textElement: any): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 历史: 同 onebot/api/msg.ts 的特定会话特殊处理, 改为可配置数组, 默认空=不跳过。
|
||||
// 如需旧行为: NAPCAT_SPECIAL_PEER_UINS='284840486,1094950020'
|
||||
const SPECIAL_PEER_UINS: string[] = (process.env['NAPCAT_SPECIAL_PEER_UINS'] ?? '')
|
||||
.split(',')
|
||||
.map(s => s.trim())
|
||||
.filter(s => /^\d+$/.test(s));
|
||||
|
||||
function replyElementToText (replyElement: any, msg: RawMessage, recursiveLevel: number): string {
|
||||
const recordMsgOrNull = msg.records.find((record) => replyElement.sourceMsgIdInRecords === record.msgId);
|
||||
return `[回复消息 ${recordMsgOrNull && recordMsgOrNull.peerUin !== '284840486' && recordMsgOrNull.peerUin !== '1094950020'
|
||||
return `[回复消息 ${recordMsgOrNull && !SPECIAL_PEER_UINS.includes(recordMsgOrNull.peerUin)
|
||||
? rawMessageToText(recordMsgOrNull, recursiveLevel + 1)
|
||||
: `未找到消息记录 (MsgId = ${replyElement.sourceMsgIdInRecords})`
|
||||
}]`;
|
||||
|
||||
Reference in new issue
Block a user