Open suntong opened 4 years ago
The wechaty-puppet-mock
now will not emit any message any more by default.
You need to specify an Environment
for our mocking if you want the mocking environment to interact with your bot.
See: https://github.com/wechaty/wechaty-puppet-mock#mocker--environment
OK. Thanks.
So, how to make use of the wechaty-puppet-mock
now?
Looking from the source, it seems to me that I need to launch a "Mocker & Environment" instant first, then start the "Puppet Mock" instant, as my normal client, is it? Apart from SimpleEnvironment()
, what else Environment() can we choose?
Also, can we still change the puppet on the fly from out side as it used to be?
I.e., previously it was only a matter of switching to WECHATY_PUPPET=wechaty-puppet-mock
from ipad or puppeteer, to start
node examples/ding-dong-bot.js
without changing/touch the script at all. Can we still do that now? Thx!
Bump, Can we still do that now? Thx!
Also, can we still change the puppet on the fly from outside as it used to be?
Currently, we can only change puppet to wechaty-puppet-mock on the fly from outside, but if you want to emit auto-generated messages, it can not be set on the fly yet. (PR will be welcome!)
We can start to receive the auto-generated message from puppet mock by the following code:
import {
PuppetMock,
Mocker,
SimpleEnvironment,
} from 'wechaty-puppet-mock'
const mocker = new Mocker()
mocker.use(SimpleEnvironment())
const puppet = new PuppetMock({ mocker })
const wechaty = new Wechaty({ puppet })
wechaty.start()
// The Mocker will start perform the SimpleEnvironment...
0. Report Issue Guide
Not fixed.
Done.
Done.
1. Versions
Which puppet are you using for wechaty? (padchat/puppeteer/padpro/...) Answer:
wechaty-puppet-mock
What is your node version? (run
node --version
) Answer: v10.21.0What os are you using Answer:
2. Describe the bug
ding-dong-bot.js can't be started with wechaty-puppet-mock
3. To Reproduce
Steps to reproduce the behavior:
require('./.util/helper')
line fromding-dong-bot.js
under
wechaty-getting-started
, runWECHATY_PUPPET=wechaty-puppet-mock WECHATY_LOG=silly node examples/ding-dong-bot.js
4. Expected behavior
Received mock messages continuously.
5. Actual behavior
Mock messages not received.
6. Full Output Logs
Show Logs
```shell $ WECHATY_PUPPET=wechaty-puppet-mock WECHATY_LOG=silly node examples/ding-dong-bot.js 19:43:45 SILL Puppet Config: WECHATY_LOG set level to silly 19:43:45 INFO Config registering process.on("unhandledRejection") for development/debug 19:43:45 VERB Config constructor() 19:43:46 VERB Wechaty constructor() 19:43:46 VERB StateSwitch constructor(Wechaty, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 19:43:46 VERB StateSwitch constructor(WechatyReady, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 19:43:46 VERB Wechaty on(scan, listener) registered 19:43:46 VERB Wechaty on(login, listener) registered 19:43:46 VERB Wechaty on(logout, listener) registered 19:43:46 VERB Wechaty on(message, listener) registered 19:43:46 VERB Wechaty7. Additional context
N.A.
[bug]