41 lines
3.0 KiB
Python
41 lines
3.0 KiB
Python
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,count=1):
|
|
global text
|
|
assert text.count(old)==count,(old[:70],text.count(old))
|
|
text=text.replace(old,new)
|
|
rep(' if not evidence:\n continue\n with getattr(self, "_pending_lock", None) or nullcontext():',
|
|
' if (not isinstance(evidence, dict) or evidence.get("account") != context["account"]\n or evidence.get("conv_id") != context["conv_id"]\n or str(evidence.get("review_id") or "") != str(review_id)):\n continue\n with getattr(self, "_pending_lock", None) or nullcontext():')
|
|
rep(' or self._review_assistant_protected(state)):\n continue\n discarded =',
|
|
' or self._review_assistant_protected(state)):\n continue\n current_event = str((state.get("database_event") or {}).get("message_id") or "")\n if current_event and current_event not in {str(item.get("dedup_key") or "")\n for item in context.get("messages") or []}:\n continue # A DB event arrived while this older snapshot was being checked.\n discarded =')
|
|
old=''' blanket_review = (self._review_mode_enabled()
|
|
and not self._review_assistant_resumed(pending_state))
|
|
rule_hit, rule_reason = (
|
|
(False, "")
|
|
if blanket_review
|
|
else self._reply_needs_review(
|
|
pending_state,
|
|
str((pending_state or {}).get("staged_user_text") or "\\n".join(
|
|
str(line) for line in (pending_state or {}).get("last_lines") or []
|
|
)),
|
|
reply_text,
|
|
)
|
|
)'''
|
|
new=''' blanket_review, rule_hit, rule_reason = self._reply_review_decision(
|
|
pending_state, str((pending_state or {}).get("staged_user_text") or "\\n".join(
|
|
str(line) for line in (pending_state or {}).get("last_lines") or [])), reply_text,
|
|
)'''
|
|
rep(old,new)
|
|
rep(' def _review_mode_enabled(self) -> bool:\n', ''' 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 _review_mode_enabled(self) -> bool:
|
|
''')
|
|
ast.parse(text)
|
|
p.write_text(text,encoding='utf-8',newline='\n')
|