Commit 7ee51e32e4b496a689ae056c2afc8e8282b1ae28

Authored by yibo
1 parent 8648cd32

fix: classifyState 剥群聊标题成员数后缀再比对

症状:群里 @ 后,FSM 循环 CHAT_LIST→click→WRONG_CHAT→BACK 死磕,
最终撞 MAX_STATE_TRANSITIONS=6 cap 放弃。

根因:进群聊页后 obn (id=/obn) 文本是 "宜创AI全员群(60)"(带成员数后缀),
而 broadcast 传的 toUserDisplayName 是 "宜创AI全员群"(从 chatroom.displayname
查的,不带后缀),严格 equals 永远 false → 永远判定 WRONG_CHAT。

修法:classifyState 拿到 obn.text 后用正则剥掉末尾 (数字),再与目标做
equals 比对。两种格式都接受(带 / 不带后缀都能匹配)。

实测(22:23:00 后):
  classifyState: obn.text=宜创AI全员群(19) normalized=宜创AI全员群
  FSM[0] state=TARGET_CHAT      ← 一步到位(不再 BACK 死磕)
  Quote bubble matched [5]
  Long-press → 引用 → @ 火星人 → 写文本 → send
  整条 3 秒走完

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
wechat_plain/scripts/lsposed-wechat-sendmsg/app/src/main/java/com/hermes/wechat/xposed/accessibility/HermesAccessibilityService.java
... ... @@ -160,9 +160,15 @@ public class HermesAccessibilityService extends AccessibilityService {
160 160 AccessibilityNodeInfo title = findNodeById(root, ID_CHAT_TITLE);
161 161 boolean isTarget = false;
162 162 if (title != null) {
163   - CharSequence t = title.getText();
  163 + CharSequence raw = title.getText();
  164 + String titleText = (raw != null) ? raw.toString() : "";
  165 + // 群聊标题带成员数后缀(如 "宜创AI全员群(60)"),剥掉 "(数字)" 再比对
  166 + String normalized = titleText.replaceAll("\\(\\d+\\)$", "").trim();
  167 + Log.d(TAG, "classifyState: obn.text=" + titleText + " normalized=" + normalized
  168 + + " target=" + pendingToUserDisplayName);
164 169 isTarget = pendingToUserDisplayName != null
165   - && pendingToUserDisplayName.equals(t != null ? t.toString() : "");
  170 + && (pendingToUserDisplayName.equals(titleText)
  171 + || pendingToUserDisplayName.equals(normalized));
166 172 title.recycle();
167 173 }
168 174 bkk.recycle();
... ...