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

Question about MessagePayload #119

Closed
su-chang opened this issue Aug 22, 2020 · 1 comment
Closed

Question about MessagePayload #119

su-chang opened this issue Aug 22, 2020 · 1 comment
Labels
question Further information is requested

Comments

@su-chang
Copy link
Member

su-chang commented Aug 22, 2020

Definition

type MessagePayload = (MessagePayloadBase & MessagePayloadRoom) | (MessagePayloadBase & MessagePayloadTo)
const payload = messageRawPayloadParser(): MessagePayload

If we want to get mentionIdList of payload, we have to claim that:

(payload as (MessagePayloadBase & MessagePayloadRoom)).mentionIdList

But MessagePayloadBase and MessagePayloadRoom are not export in wechaty-puppet, so any good idea about this issue?

@su-chang
Copy link
Member Author

Resolved by this way:

payload && 'mentionIdList' in payload

copy from:

    if (this.payload && 'mentionIdList' in this.payload) {
      const idToContact = async (id: string) => {
        const contact = this.wechaty.Contact.load(id)
        await contact.ready()
        return contact
      }
      return Promise.all(this.payload.mentionIdList?.map(idToContact) ?? [])
    }

@huan huan added the question Further information is requested label Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants