Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Puppet Memory Multiplex Problem with Multi-Instance Wechaty and Pre-Instanced Puppet #1516

Closed
linhaobin opened this issue Jul 31, 2018 · 6 comments
Labels

Comments

@linhaobin
Copy link

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":...
@huan
Copy link
Member

huan commented Jul 31, 2018

I had observed that the two Wechaty bot are sharing one puppet, which I believe it should not work.

You need two puppet for two Wechaty bot, like this:

import { Wechaty } from 'wechaty'
import PuppetPadchat from 'wechaty-puppet-padchat'

const puppet1 = new PuppetPadchat({
  token: '1111111'
})

const puppet2 = new PuppetPadchat({
  token: '222222'
})

new Wechaty({ profile: 'one', puppet: puppet1 }).start()
new Wechaty({ profile: 'two', puppet: puppet2 }).start()

Or let Wechaty instanciate your puppet:

import { Wechaty } from 'wechaty'

new Wechaty({ 
  profile: 'one', 
  puppet: 'wechaty-puppet-padchat', 
  puppetOptions: { token: '1111111' },
).start()
new Wechaty({ 
  profile: 'two', 
  puppet: 'wechaty-puppet-padchat',
  puppetOptions: { token: '2222222' },
}).start()

@huan huan changed the title not autologin One puppet should only be used for one Wechaty bot Jul 31, 2018
@linhaobin
Copy link
Author

Sorry, my code is like this, but not auto login

import { Wechaty } from 'wechaty'
import PuppetPadchat from 'wechaty-puppet-padchat'

const puppet1 = new PuppetPadchat({
  token: '1111111'
})

const puppet2 = new PuppetPadchat({
  token: '222222'
})

new Wechaty({ profile: 'one', puppet: puppet1 }).start()
new Wechaty({ profile: 'two', puppet: puppet2 }).start()

auto login to work, like this:

import { Wechaty } from 'wechaty'

new Wechaty({ 
  profile: 'one', 
  puppet: 'wechaty-puppet-padchat', 
  puppetOptions: { token: '1111111' },
).start()
new Wechaty({ 
  profile: 'two', 
  puppet: 'wechaty-puppet-padchat',
  puppetOptions: { token: '2222222' },
}).start()

@huan
Copy link
Member

huan commented Aug 1, 2018

Thanks for updating.

What's the Wechaty version you are using, could you please try the latest version of v0.19.119?

@huan huan added the bug label Aug 1, 2018
@linhaobin
Copy link
Author

Thanks, work in v0.19.119

@huan huan changed the title One puppet should only be used for one Wechaty bot Fix Puppet Memory Multiplex Problem with Multi-Instance Wechaty and Pre-Instanced Puppet Aug 1, 2018
@huan
Copy link
Member

huan commented Aug 1, 2018

Glad to hear that.

Can we close this issue for now?

@linhaobin
Copy link
Author

yes, thnaks

@huan huan closed this as completed Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants