test_send.sh 1.03 KB
#!/usr/bin/env bash
# Test Route A send hook via adb
# Usage: bash test_send.sh <wxid> "<text>"
# Example: bash test_send.sh wxid_abc123 "Hello from hook"
#
# NOTE: This is a TEST SCRIPT — read-only / dry-run by default.
#       Set DRY_RUN=0 to actually trigger the broadcast.

set -euo pipefail

TALKER="${1:-}"
TEXT="${2:-}"
DRY_RUN="${DRY_RUN:-1}"  # Default: print only, don't fire

if [ -z "$TALKER" ] || [ -z "$TEXT" ]; then
  echo "Usage: DRY_RUN=0 bash test_send.sh <talker> '<text>'"
  echo "  talker examples:"
  echo "    wxid_abc123          (1-on-1)"
  echo "    12345678901@chatroom (group)"
  exit 1
fi

CMD="adb shell am broadcast \
  -a com.hermes.wechat.SEND_MSG_INTERNAL \
  --es to \"$TALKER\" \
  --es text \"$TEXT\""

echo "Command to run:"
echo "  $CMD"
echo ""

if [ "$DRY_RUN" = "1" ]; then
  echo "[DRY RUN] Not executing. Set DRY_RUN=0 to actually send."
else
  echo "[SENDING] Executing broadcast..."
  eval "$CMD"
  echo ""
  echo "Check logcat for: [WeChatSendHook]"
  echo "  adb logcat -s Xposed:D | grep WeChatSendHook"
fi