Fix Puppet Memory Multiplex Problem with Multi-Instance Wechaty and Pre-Instanced Puppet
Created by: linhaobin
versions
"wechaty": "0.19.117",
"wechaty-puppet-padchat": "0.9.8"
first
import { Wechaty } from 'wechaty'
import PuppetPadchat from 'wechaty-puppet-padchat'
const puppet = new PuppetPadchat({
token: 'xxxxx'
})
new Wechaty({ profile: 'one', puppet }).start()
new Wechaty({ profile: 'two', puppet }).start()
end the process, run again
// not autologin
new Wechaty({ profile: 'two', puppet }).start()
new Wechaty({ profile: 'one', puppet }).start()
I think it is related to PuppetPadchat#toString
public toString () {
const text = super.toString()
return text + `/PuppetPadchat#${this.padchatCounter}`
}
one.memory-card.json
{"\rPuppet#0<PuppetPadchat>()/PuppetPadchat#0\nWECHATY_PUPPET_PADCHAT":...
two.memory-card.json
{"\rPuppet#1<PuppetPadchat>()/PuppetPadchat#1\nWECHATY_PUPPET_PADCHAT":...