How to use the wechaty-puppet.MessageType.Attachment 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 / src / puppet-padchat / pure-function-helpers / message-type.ts View on Github external
type = MessageType.Image
      // console.log(rawPayload)
      break

    case PadchatMessageType.Voice:
      type = MessageType.Audio
      // console.log(rawPayload)
      break

    case PadchatMessageType.Emoticon:
      type = MessageType.Emoticon
      // console.log(rawPayload)
      break

    case PadchatMessageType.App:
      type = MessageType.Attachment
      // console.log(rawPayload)
      break

    case PadchatMessageType.Video:
      type = MessageType.Video
      // console.log(rawPayload)
      break

    case PadchatMessageType.Sys:
      type = MessageType.Unknown
      break

    case PadchatMessageType.ShareCard:
      type = MessageType.Contact
      break
github wechaty / wechaty-puppet-padplus / src / pure-function-helpers / message-type.ts View on Github external
type = MessageType.Image
      // console.log(rawPayload)
      break

    case PadplusMessageType.Voice:
      type = MessageType.Audio
      // console.log(rawPayload)
      break

    case PadplusMessageType.Emoticon:
      type = MessageType.Emoticon
      // console.log(rawPayload)
      break

    case PadplusMessageType.App:
      type = MessageType.Attachment
      // console.log(rawPayload)
      break

    case PadplusMessageType.Location:
      type = MessageType.Location
      // console.log(rawPayload)
      break

    case PadplusMessageType.Video:
      type = MessageType.Video
      // console.log(rawPayload)
      break

    case PadplusMessageType.Sys:
      type = MessageType.Unknown
      break
github wechaty / wechaty-puppet-padplus / src / pure-function-helpers / message-raw-payload-parser.ts View on Github external
const payloadBase = {
    id        : rawPayload.msgId,
    timestamp : rawPayload.createTime / 1000,   // Padplus message timestamp is seconds
    type,
  } as {
    id        : string,
    timestamp : number,
    type      : MessageType,
    filename? : string,
    url?      : string,
  }

  if (type === MessageType.Image
      || type === MessageType.Audio
      || type === MessageType.Video
      || type === MessageType.Attachment
  ) {
    payloadBase.filename = messageFileName(rawPayload) || undefined
  }

  if (type === MessageType.Emoticon) {
    payloadBase.url = rawPayload.url
  }

  let fromId: undefined | string
  let roomId: undefined | string
  let toId:   undefined | string

  let text:   undefined | string

  let mentionIdList: undefined | string[]
github wechaty / wechaty / src / puppet-padchat / pure-function-helpers / message-raw-payload-parser.ts View on Github external
const payloadBase = {
    id        : rawPayload.msg_id,
    timestamp : rawPayload.timestamp,   // Padchat message timestamp is seconds
    type      : type,
  } as {
    id        : string,
    timestamp : number,
    type      : MessageType,
    filename? : string,
  }

  if (   type === MessageType.Image
      || type === MessageType.Audio
      || type === MessageType.Video
      || type === MessageType.Attachment
  ) {
    payloadBase.filename = messageFileName(rawPayload) || undefined
  }

  let fromId: undefined | string = undefined
  let roomId: undefined | string = undefined
  let toId:   undefined | string = undefined

  let text:   undefined | string = undefined

  /**
   * 1. Set Room Id
   */
  if (isRoomId(rawPayload.from_user)) {
    roomId = rawPayload.from_user
  } else if (isRoomId(rawPayload.to_user)) {
github wechaty / wechaty-puppet-padplus / src / pure-function-helpers / message-raw-payload-parser.ts View on Github external
* 6. Set app payload type
   */
  if (type === MessageType.Attachment) {
    const appPayload = await appMessageParser(rawPayload)
    if (appPayload) {
      switch (appPayload.type) {
        case WechatAppMessageType.Text:
          payload.type = MessageType.Text
          payload.text = appPayload.title
          payload.filename = undefined
          break
        case WechatAppMessageType.Url:
          payload.type = MessageType.Url
          break
        case WechatAppMessageType.Attach:
          payload.type = MessageType.Attachment
          payload.filename = appPayload.title
          break
        case WechatAppMessageType.ChatHistory:
          payload.type = MessageType.ChatHistory
          break
        case WechatAppMessageType.MiniProgram:
        case WechatAppMessageType.MiniProgramApp:
          payload.type = MessageType.MiniProgram
          break
        case WechatAppMessageType.RedEnvelopes:
        case WechatAppMessageType.Transfers:
          payload.type = MessageType.Money
          break
        case WechatAppMessageType.RealtimeShareLocation:
          payload.type = MessageType.Location
          break