Skip to content

Commit 2b7cef2

Browse files
fix(chat): initialize user_replied state for private messages
Explicitly initialize user_replied to False for send_private_message actions to ensure consistent state tracking. Remove redundant conditional branch in history display logic since the state is now always initialized.
1 parent 60e983c commit 2b7cef2

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/plugins/nonebot_plugin_chat/core/main_session.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,9 @@ async def get_action_str(self, action: BoredAction, state: ActionState) -> Optio
167167
action.subject,
168168
time_str,
169169
)
170-
elif state.get("user_replied") is False:
171-
return await lang.text(
172-
"main_session.history.send_private_message.no_reply",
173-
self.lang_str,
174-
action.target_nickname,
175-
action.subject,
176-
)
177170
else:
178171
return await lang.text(
179-
"main_session.history.send_private_message.default",
172+
"main_session.history.send_private_message.no_reply",
180173
self.lang_str,
181174
action.target_nickname,
182175
action.subject,
@@ -255,8 +248,10 @@ async def process_boredom(self) -> None:
255248
try:
256249
response = type_validate_python(BoredActionResponse, {"response": json.loads(message)})
257250
action = response.response
258-
# 初始化空的 action_state
251+
# 初始化 action_state,对于 send_private_message 默认标记为未回复
259252
action_state: ActionState = {}
253+
if action.type == "send_private_message":
254+
action_state["user_replied"] = False
260255
self.action_history.append((datetime.now(), action, action_state))
261256
await self.handle_action(action, fetcher)
262257
except Exception:

0 commit comments

Comments
 (0)