Skip to content

Commit 574f1ca

Browse files
committed
🐛 将'willing'字典的键从整数改为字符串修复解析
1 parent c41b0eb commit 574f1ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/nonebot_plugin_nyaturingtest/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def __feedback_stage(
679679
# 更新对话状态
680680
if not isinstance(response_dict["willing"], dict):
681681
raise ValueError("Feedback validation error: 'willing' is not a dict: " + str(response_dict))
682-
if not all(key in [0, 1, 2] for key in response_dict["willing"].keys()):
682+
if not all(key in ["0", "1", "2"] for key in response_dict["willing"].keys()):
683683
raise ValueError("Feedback validation error: 'willing' keys are not 0, 1 or 2: " + str(response_dict))
684684
if not all(
685685
isinstance(value, int | float) and 0.0 <= value <= 1.0 for value in response_dict["willing"].values()
@@ -688,13 +688,13 @@ def __feedback_stage(
688688
"Feedback validation error: 'willing' values are not in range [0.0, 1.0]: " + str(response_dict)
689689
)
690690
# 评估转换到状态0的概率
691-
idle_chance = response_dict["willing"][0]
691+
idle_chance = response_dict["willing"]["0"]
692692
logger.debug(f"nyabot潜水意愿:{idle_chance}")
693693
# 评估转换到状态1的概率
694-
bubble_chance = response_dict["willing"][1]
694+
bubble_chance = response_dict["willing"]["1"]
695695
logger.debug(f"nyabot冒泡意愿:{bubble_chance}")
696696
# 评估转换到状态2的概率
697-
chat_chance = response_dict["willing"][2]
697+
chat_chance = response_dict["willing"]["2"]
698698
logger.debug(f"nyabot对话意愿:{chat_chance}")
699699

700700
random_value = random.uniform(0.0, 1.0)

0 commit comments

Comments
 (0)