How to use the wechaty-puppet.ContactType.Unknown function in wechaty-puppet

To help you get started, we’ve selected a few wechaty-puppet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wechaty / wechaty-puppet-padplus / src / pure-function-helpers / contact-raw-payload-parser.ts View on Github external
*  signature: '',
     *  small_head: '',
     *  status: 0,
     *  stranger: '',
     *  ticket: '',
     *  user_name: '' }
     */
    // console.log(rawPayload)
    throw Error('cannot get user_name from raw payload: ' + JSON.stringify(rawPayload))
  }

  if (isRoomId(rawPayload.userName)) {
    throw Error('Room Object instead of Contact!')
  }

  let contactType = ContactType.Unknown
  if (isContactOfficialId(rawPayload.userName) || rawPayload.verifyFlag !== 0) {
    contactType = ContactType.Official
  } else {
    contactType = ContactType.Personal
  }
  let friend = false
  if (rawPayload.stranger && rawPayload.stranger !== '0' && rawPayload.verifyFlag === 0) {
    friend = true
  }
  const payload: ContactPayload = {
    alias     : rawPayload.remark,
    avatar    : rawPayload.bigHeadUrl,
    city      : rawPayload.city,
    friend,
    gender    : rawPayload.sex,
    id        : rawPayload.userName,
github wechaty / wechaty / src / puppet-padchat / pure-function-helpers / contact-raw-payload-parser.ts View on Github external
*  signature: '',
     *  small_head: '',
     *  status: 0,
     *  stranger: '',
     *  ticket: '',
     *  user_name: '' }
     */
    // console.log(rawPayload)
    throw Error('cannot get user_name from raw payload: ' + JSON.stringify(rawPayload))
  }

  if (isRoomId(rawPayload.user_name)) {
    throw Error('Room Object instead of Contact!')
  }

  let contactType = ContactType.Unknown
  if (isContactOfficialId(rawPayload.user_name)) {
    contactType = ContactType.Official
  } else {
    contactType = ContactType.Personal
  }

  const payload: ContactPayload = {
    alias     : rawPayload.remark,
    avatar    : rawPayload.big_head,
    city      : rawPayload.city,
    gender    : rawPayload.sex,
    id        : rawPayload.user_name,
    name      : rawPayload.nick_name,
    province  : rawPayload.provincia,
    signature : (rawPayload.signature).replace('+', ' '),          // Stay+Foolish
    type      : contactType,