feat: 更新映射表以包含福袋详情信息,增强预约逻辑
This commit is contained in:
1 parent
3fbd2b2d85
commit
b940c91e2e
1 file changed
+21
-62
@@ -2051,25 +2051,43 @@ def get_fudai_contain(analyser, renwu: int = 2) -> Tuple[str, str, int, int, flo
|
||||
# log_type="INFO",
|
||||
# )
|
||||
|
||||
# 更新映射表中的标题信息(如果存在该位置的记录)
|
||||
# 更新映射表中的标题信息和福袋详情(如果存在该位置的记录)
|
||||
try:
|
||||
room_pos = int(getattr(analyser, "room_pos", 0) or 0)
|
||||
room_pos_map = getattr(analyser, "_room_pos_to_title_map", {})
|
||||
if room_pos in room_pos_map:
|
||||
# 更新标题信息
|
||||
room_pos_map[room_pos]["title"] = live_room_title_raw
|
||||
room_pos_map[room_pos]["title_raw"] = live_room_title_text_raw
|
||||
|
||||
# 更新福袋详细信息
|
||||
room_pos_map[room_pos]["has_fudai"] = True
|
||||
room_pos_map[room_pos]["fudai_content"] = fudai_content_text
|
||||
room_pos_map[room_pos]["fudai_detail"] = {
|
||||
"content": fudai_content_text,
|
||||
"time_text": time_text,
|
||||
"participants": participants,
|
||||
"copies": copies,
|
||||
"prize_value_yuan": prize_value_yuan,
|
||||
"button_text": getattr(analyser, "button_text_raw", ""),
|
||||
"timestamp": time.time(),
|
||||
}
|
||||
room_pos_map[room_pos]["timestamp"] = time.time()
|
||||
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] 更新映射表标题信息",
|
||||
"[预约] 更新映射表标题和福袋详情信息",
|
||||
room_pos=room_pos,
|
||||
title=live_room_title_raw[:30] if live_room_title_raw else "",
|
||||
fudai_content=fudai_content_text[:30] if fudai_content_text else "",
|
||||
prize_value_yuan=prize_value_yuan,
|
||||
log_type="DEBUG",
|
||||
)
|
||||
except Exception as e_update:
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"错误",
|
||||
"更新映射表标题信息失败",
|
||||
"更新映射表标题和福袋详情信息失败",
|
||||
error=str(e_update),
|
||||
level="WARNING",
|
||||
)
|
||||
@@ -5589,65 +5607,6 @@ def basic_join_decision(
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 记录高价值预约后,立即记录房间标题到映射表,确保一个直播间只记录一次
|
||||
# 注意:福袋信息已在函数开始处设置,这里不再重复设置
|
||||
try:
|
||||
if hasattr(analyser, "_record_room_title_and_pos"):
|
||||
analyser._record_room_title_and_pos()
|
||||
else:
|
||||
# 如果没有这个方法,手动记录
|
||||
try:
|
||||
room_pos_current = int(
|
||||
getattr(analyser, "room_pos", room_pos) or room_pos
|
||||
)
|
||||
room_pos_map = getattr(
|
||||
analyser, "_room_pos_to_title_map", {}
|
||||
)
|
||||
if room_pos_current not in room_pos_map:
|
||||
room_pos_map[room_pos_current] = (
|
||||
room_title,
|
||||
room_title_raw,
|
||||
)
|
||||
analyser._room_pos_to_title_map = room_pos_map
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] basic_join_decision:记录位置信息到运行时映射表",
|
||||
room_pos=room_pos_current,
|
||||
room_title=(
|
||||
room_title[:50] if room_title else ""
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
# 尝试将映射序列化到状态文件,供 GUI 使用
|
||||
try:
|
||||
from douyin.reservation import (
|
||||
douyin_reservation_handler as _rh,
|
||||
)
|
||||
|
||||
if hasattr(_rh, "_dump_room_pos_map_to_state"):
|
||||
try:
|
||||
_rh._dump_room_pos_map_to_state(
|
||||
analyser
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e_inner:
|
||||
try:
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] basic_join_decision:记录位置信息到运行时映射表失败",
|
||||
error=str(e_inner),
|
||||
error_type=type(e_inner).__name__,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 记录预约,并检查队列是否已满
|
||||
queue_full_flag = [False]
|
||||
|
||||
|
||||
Reference in new issue
Block a user