from pathlib import Path import ast for root in (Path('C:/kefu/wechat_rpa'), Path('C:/wechat_rpa')): p=root/'wechat_bot.py' text=p.read_text(encoding='utf-8') def rep(old,new): global text assert text.count(old)==1,old[:70] text=text.replace(old,new) rep(''' def _reply_review_decision(self, pending_state, customer_text, reply_text): blanket = self._review_mode_enabled() and not self._review_assistant_resumed(pending_state) hit, reason = (False, "") if blanket else self._reply_needs_review(pending_state, customer_text, reply_text) return blanket, hit, reason ''', ''' def _reply_review_decision(self, pending_state, customer_text, reply_text): resumed = held = False assistant = self._get_review_assistant(verify=True) if assistant is not None: try: context = self._review_assistant_context(pending_state or {}) if context: held = assistant.has_pending(context["conv_id"]) resumed = assistant.resumed(context["conv_id"]) and not held except Exception: held = True # Missing review state cannot grant an automatic send. blanket = self._review_mode_enabled() and not resumed hit, reason = self._reply_needs_review(pending_state, customer_text, reply_text) return blanket, bool(hit or held), reason or ("本会话仍有待审核消息,等待同账号人工回复" if held else "") ''') rep(''' pending_state["awaiting_review"] = True pending_state["review_requested_at"] = time.time()''', ''' pending_state["awaiting_review"] = True pending_state.pop("assistant_review_id", None) pending_state["review_requested_at"] = time.time()''') rep(''' last = context.get("last_message") or {} if last and not last.get("is_self") and last.get("dedup_key"): ''', ''' human_time = float(evidence.get("send_time") or 0) human_row = int(evidence.get("rowid") or 0) later = [item for item in context.get("messages") or [] if item.get("is_self") is False and item.get("dedup_key") and item.get("account", context["account"]) == context["account"] and item.get("conv_id", context["conv_id"]) == context["conv_id"] and (float(item.get("send_time") or 0) > human_time or (float(item.get("send_time") or 0) == human_time and int(item.get("rowid") or 0) > human_row))] last = max(later, key=lambda item: (float(item.get("send_time") or 0), int(item.get("rowid") or 0))) if later else {} if last: ''') ast.parse(text) p.write_text(text,encoding='utf-8',newline='\n')