Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

撤回消息中的fromId和toId存在逻辑问题 #34

Closed
su-chang opened this issue Jan 6, 2021 · 2 comments
Closed

撤回消息中的fromId和toId存在逻辑问题 #34

su-chang opened this issue Jan 6, 2021 · 2 comments
Assignees
Labels
bug Something isn't working P1

Comments

@su-chang
Copy link
Member

su-chang commented Jan 6, 2021

fromId 主动撤回消息账号的ID

toId 接收撤回消息通知账号的ID

text 字段中需要存放已撤回消息的ID,即xml中的newmsgid,便于查找已撤回的消息内容

你可以参考以下代码:

const recalledPayload = await recalledPayloadParser(rawPayload)
const pattern = [
  /"(.+)" 撤回了一条消息/,
  /"(.+)" has recalled a message./,
]
const patternSelf = [
  /你撤回了一条消息/,
  /You recalled a message/,
]
if (recalledPayload) {
  const isRecalled = pattern.some(regex => regex.test(recalledPayload.replaceMsg))
  const isRecalledSelf = patternSelf.some(regex => regex.test(recalledPayload.replaceMsg))
  if (isRecalled || isRecalledSelf) {
    text = recalledPayload.newMsgId
    if (isRecalledSelf) {
      fromId = rawPayload.from_wxid
      if (isRoomId(rawPayload.to_wxid)) {
        roomId = rawPayload.to_wxid
      } else if (isContactId(rawPayload.to_wxid)) {
        toId = rawPayload.to_wxid
      }
    }
  } else {
    payloadBase.type = MessageType.Unknown
  }
} else {
  payloadBase.type = MessageType.Unknown
}
@padlocal padlocal added P1 bug Something isn't working labels Jan 14, 2021
@padlocal padlocal self-assigned this Jan 18, 2021
@dchaofei
Copy link

go-wechaty 使用 padlocal puppet 也遇到了这个问题: wechaty/go-wechaty#87

@padlocal
Copy link
Collaborator

padlocal commented Jun 8, 2022

Thanks for your hints. Fixed and will be release in version wechaty-puppet-padlocal@1.11.19

@padlocal padlocal closed this as completed Jun 8, 2022
padlocal added a commit that referenced this issue Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

No branches or pull requests

3 participants