@@ -31,16 +31,16 @@ class ReplyAction(BaseAction):
3131 action_require : list [str ] = [
3232 "你想要闲聊或者随便附和" ,
3333 "有人提到你" ,
34- "如果你刚刚进行了回复,不要对同一个话题重复回应"
34+ "如果你刚刚进行了回复,不要对同一个话题重复回应" ,
3535 ]
3636
3737 associated_types : list [str ] = ["text" ]
3838
3939 enable_plugin = True
40-
40+
4141 # 激活类型设置
4242 focus_activation_type = ActionActivationType .ALWAYS
43-
43+
4444 # 模式启用设置 - 回复动作只在Focus模式下使用
4545 mode_enable = ChatMode .FOCUS
4646
@@ -89,12 +89,12 @@ async def handle_action(self) -> Tuple[bool, str]:
8989 cycle_timers = self .cycle_timers ,
9090 thinking_id = self .thinking_id ,
9191 )
92-
92+
9393 await self .store_action_info (
9494 action_build_into_prompt = False ,
9595 action_prompt_display = f"{ reply_text } " ,
9696 )
97-
97+
9898 return success , reply_text
9999
100100 async def _handle_reply (
@@ -115,30 +115,29 @@ async def _handle_reply(
115115 chatting_observation : ChattingObservation = next (
116116 obs for obs in self .observations if isinstance (obs , ChattingObservation )
117117 )
118-
118+
119119 reply_to = reply_data .get ("reply_to" , "none" )
120-
120+
121121 # sender = ""
122122 target = ""
123123 if ":" in reply_to or ":" in reply_to :
124124 # 使用正则表达式匹配中文或英文冒号
125- parts = re .split (pattern = r' [::]' , string = reply_to , maxsplit = 1 )
125+ parts = re .split (pattern = r" [::]" , string = reply_to , maxsplit = 1 )
126126 if len (parts ) == 2 :
127127 # sender = parts[0].strip()
128128 target = parts [1 ].strip ()
129129 anchor_message = chatting_observation .search_message_by_text (target )
130130 else :
131131 anchor_message = None
132-
133- if anchor_message :
132+
133+ if anchor_message :
134134 anchor_message .update_chat_stream (self .chat_stream )
135135 else :
136136 logger .info (f"{ self .log_prefix } 未找到锚点消息,创建占位符" )
137137 anchor_message = await create_empty_anchor_message (
138138 self .chat_stream .platform , self .chat_stream .group_info , self .chat_stream
139139 )
140140
141-
142141 success , reply_set = await self .replyer .deal_reply (
143142 cycle_timers = cycle_timers ,
144143 action_data = reply_data ,
@@ -158,8 +157,9 @@ async def _handle_reply(
158157
159158 return success , reply_text
160159
161-
162- async def store_action_info (self , action_build_into_prompt : bool = False , action_prompt_display : str = "" , action_done : bool = True ) -> None :
160+ async def store_action_info (
161+ self , action_build_into_prompt : bool = False , action_prompt_display : str = "" , action_done : bool = True
162+ ) -> None :
163163 """存储action执行信息到数据库
164164
165165 Args:
@@ -188,9 +188,9 @@ async def store_action_info(self, action_build_into_prompt: bool = False, action
188188 chat_info_platform = chat_stream .platform ,
189189 user_id = chat_stream .user_info .user_id if chat_stream .user_info else "" ,
190190 user_nickname = chat_stream .user_info .user_nickname if chat_stream .user_info else "" ,
191- user_cardname = chat_stream .user_info .user_cardname if chat_stream .user_info else ""
191+ user_cardname = chat_stream .user_info .user_cardname if chat_stream .user_info else "" ,
192192 )
193193 logger .debug (f"{ self .log_prefix } 已存储action信息: { action_prompt_display } " )
194194 except Exception as e :
195195 logger .error (f"{ self .log_prefix } 存储action信息时出错: { e } " )
196- traceback .print_exc ()
196+ traceback .print_exc ()
0 commit comments