puppet-supports icon indicating copy to clipboard operation
puppet-supports copied to clipboard

ChatHistory 转发的聊天历史记录无法获取

Open VEADoc opened this issue 4 years ago • 0 comments

1. Versions

What is your wechaty version?

Answer: ^0.62.3

Which puppet are you using for wechaty? (puppeteer/padlocal/service...)

Answer: wechaty-puppet-service

What is your wechaty-puppet-XXX(padchat/puppeteer/) version?

Answer: ^0.30.2

What is your node version? (run node --version)

Answer: v16.10.0

What os are you using

Answer: macOS Catalina (10.15.7)

2. Describe the bug

bot.on('message') 监听函数获取不到群里转发的聊天历史记录

3. To Reproduce

import { Message, Wechaty } from 'wechaty'
import { MessageType } from 'wechaty-puppet'
const WxVoice = require('wx-voice');
var voice = new WxVoice();

// 错误处理
voice.on("error", (err: any) => console.log(err));

// Initializing the bot
const bot = new Wechaty({
    name: 'starter-bot', puppet: 'wechaty-puppet-service'
})

async function onMessage(message: Message) {
    console.log(message.type())

    console.log('message come in')

    switch (message.type()) {
        case MessageType.Audio:
            const fileBox = await message.toFileBox()
            const fileName = fileBox.name
            await fileBox.toFile(fileName)
            voice.decode(
                fileName, "output.mp3", { format: "mp3" },
                (file: any) => console.log(file));
            break;
        case MessageType.Image:
            const imgfileBox = await message.toFileBox()
            await imgfileBox.toFile(imgfileBox.name)
            break;
        case MessageType.Text:
            console.log(message.text())

            break;
        case MessageType.Video:
            const videofileBox = await message.toFileBox()
            await videofileBox.toFile(videofileBox.name)
                
            break;
        default:
            console.log(`Unknown ${message.type()}`)
    }
    console.log(`Message: ${message}`)
}

// Starting the bot
bot
    .on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
    .on('login', user => console.log(`User ${user} logged in`))
    .on('message', onMessage)
    .on('ready', res => {
        console.log(res)
    })
    .start()

4. Expected behavior

希望这个事件能捕获到,如果可以的话,自行解析保存 聊天历史记录

5. Actual behavior

当前在群里发送了聊天历史记录的时候 onMessage 函数 并未捕捉到

VEADoc avatar Sep 25 '21 08:09 VEADoc