wechaty / puppet-wechat4u

Wechat4u Puppet for Wechaty
https://www.npmjs.com/package/wechaty-puppet-wechat4u
Apache License 2.0
114 stars 38 forks source link

forward picrure always fail. #43

Closed JuoJuo closed 1 year ago

JuoJuo commented 2 years ago

forward picrure always fail.

15:56:01 ERR Message forward(Room<测试2>) exception: AssertionError [ERR_ASSERTION]: -1 == 0
15:56:01 ERR Message forward(Room<测试2>) exception: AssertionError [ERR_ASSERTION]: -1 == 0
uncaughtException AssertionError [ERR_ASSERTION]: -1 == 0
    at Object.equal (C:\Users\HASEE\Desktop\robot-wx\node_modules\.pnpm\wechat4u@0.7.8\node_modules\wechat4u\lib\util\global.js:69:24)
    at C:\Users\HASEE\Desktop\robot-wx\node_modules\.pnpm\wechat4u@0.7.8\node_modules\wechat4u\lib\core.js:931:24
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async PuppetWechat4u.messageForward (C:\Users\HASEE\Desktop\robot-wx\node_modules\.pnpm\wechaty-puppet-wechat4u@1.13.11_wechaty-puppet@1.20.2\node_modules\wechaty-puppet-wechat4u\dist\cjs\src\puppet-wechat4u.js:669:9)
    at async WechatifiedUserClass.forward (C:\Users\HASEE\Desktop\robot-wx\node_modules\.pnpm\wechaty@1.20.2\node_modules\wechaty\dist\cjs\src\user-modules\message.js:780:27)
    at async C:\Users\HASEE\Desktop\robot-wx\src\onLogin.js:76:17
    at async iterateToRooms (C:\Users\HASEE\Desktop\robot-wx\src\onLogin.js:38:7)
    at async C:\Users\HASEE\Desktop\robot-wx\src\onLogin.js:75:15 {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: -1,
  expected: 0,
  operator: '==',
  response: [Object],
  tips: '转发消息失败'
}
leochen-g commented 1 year ago

ok, I will check it

JuoJuo commented 1 year ago

thanks

JuoJuo commented 1 year ago

@leochen-g have you found out why?

leochen-g commented 1 year ago

@leochen-g have you found out why?

I've tested it and found no problems. Perhaps you need to give a mini case.

JuoJuo commented 1 year ago
"wechaty": "^1.0.0",
"wechaty-puppet-wechat4u": "^1.13.11"
const { WechatyBuilder } = require('wechaty');
const { PuppetWechat4u } = require('wechaty-puppet-wechat4u');

const wechaty = WechatyBuilder.build({
  puppet: new PuppetWechat4u(),
  name: 'www',
});
wechaty
  .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', async msg => {
    const room = msg.room();
    if (room  && msg.type() === wechaty.Message.Type.Image) {
      await msg.forward(room);
    }
  });
wechaty.start();

@leochen-g by the way can you give me a starter code for forward img?

leochen-g commented 1 year ago

https://github.com/nodeWechat/wechat4u/pull/309

I have submitted PR to wechat4u, please keep following.

leochen-g commented 1 year ago

It is normal for you to forward messages from contacts

JuoJuo commented 1 year ago

@leochen-g thanks! It works fine. 👍