fix: 官方抽奖判断未获取到内容 (#445)

Fixed #445

增加ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes 判断
This commit is contained in:
OPPO9008 2025-05-06 14:58:31 +08:00 committed by GitHub
parent 1832f6d52b
commit f5f63bcc91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,22 +103,41 @@ function parseDynamicCard(data) {
/* 转发描述 */
obj.description = '';
let _total_len = 0;
ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
obj.ctrl.push({
data: node.rid,
location: _total_len,
length: node.text.length,
type: 1
});
}
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.hasOfficialLottery = true;
}
obj.description += node.orig_text;
_total_len += node.text.length;
});
if (Array.isArray(ditem?.modules?.module_dynamic?.desc?.rich_text_nodes)) {
ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
obj.ctrl.push({
data: node.rid,
location: _total_len,
length: node.text.length,
type: 1
});
}
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.hasOfficialLottery = true;
}
obj.description += node.orig_text;
_total_len += node.text.length;
});
} else {
ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => {
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
obj.ctrl.push({
data: node.rid,
location: _total_len,
length: node.text.length,
type: 1
});
}
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.hasOfficialLottery = true;
}
obj.description += node.orig_text;
_total_len += node.text.length;
});
}
/* 预约抽奖信息 */
obj.reserve_id = ditem?.modules?.module_dynamic?.additional?.reserve?.rid || 0;
obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '信息丢失';
@ -166,13 +185,23 @@ function parseDynamicCard(data) {
obj.origin_hasOfficialLottery = false;
/* 转发描述 */
obj.origin_description = '';
ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.origin_hasOfficialLottery = true;
}
obj.origin_description += node.orig_text;
});
if (Array.isArray(ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes)) {
ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.origin_hasOfficialLottery = true;
}
obj.origin_description += node.orig_text;
});
} else {
ditem?.orig.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => {
/* 是否有官方抽奖 */
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
obj.origin_hasOfficialLottery = true;
}
obj.origin_description += node.orig_text;
});
}
}
} catch (e) {
log.error('动态卡片解析', e);