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

Using hotImport under V0.17+ #1484

Closed
suntong opened this issue Jul 15, 2018 · 3 comments
Closed

Using hotImport under V0.17+ #1484

suntong opened this issue Jul 15, 2018 · 3 comments

Comments

@suntong
Copy link
Contributor

suntong commented Jul 15, 2018

How to make use of the following code under V0.17?

https://github.com/Chatie/wechaty/blob/8be801e882936f28c67c616a353acb50c5892b32/src/wechaty.ts#L489-L507

Would https://github.com/Chatie/wechaty/commits/master/examples/hot-import-bot
or https://github.com/Chatie/wechaty/tree/master/examples/monster
still be the viable options?

I tried the examples/monster with WECHATY_PUPPET=puppeteer and WECHATY_LOG=verbose, and get the following log.
I.e., I didn't seen the critical onModulePath() hotImpor message being logged.

What I'm missing?
What should the correct log be, for me to compare to?

Oh, I didn't login. Let me try logging in first...

PS. the onModulePath() hotImpor at
https://github.com/Chatie/wechaty/blob/8be801e882936f28c67c616a353acb50c5892b32/src/wechaty.ts#L491
should be onModulePath() hotImport, right?

Thx

Show Logs

output logs

16:50:35 INFO Config registering process.on("unhandledRejection") for development/debug
16:50:35 VERB Config constructor()
16:50:35 VERB Wechaty contructor()
16:50:35 VERB MemoryCard constructor(default)
16:50:35 VERB StateSwitch constructor(name=Wechaty)
16:50:35 VERB Wechaty on(scan, function) registered
16:50:35 VERB Wechaty onFunction(scan)
16:50:35 VERB Wechaty on(login, function) registered
16:50:35 VERB Wechaty onFunction(login)
16:50:35 VERB Wechaty on(message, function) registered
16:50:35 VERB Wechaty onFunction(message)
16:50:35 VERB Wechaty on(friend, function) registered
16:50:35 WARN Wechaty on('friend', contact, friendRequest) is DEPRECATED. use on('friendship', friendship) instead
16:50:35 VERB Wechaty onFunction(friend)
16:50:35 INFO Wechaty start() v0.17.117 is starting...
16:50:35 VERB Wechaty puppet: undefined
16:50:35 VERB Wechaty profile: default
16:50:35 VERB Wechaty id: cjjnbe2330000ddfum4vsaef5
16:50:35 VERB StateSwitch <Wechaty> on(pending) <- (false)
16:50:35 VERB MemoryCard load() file: /path/to/monster/default.memory-card.json
16:50:35 VERB MemoryCard load() file not exist, NOOP
16:50:35 VERB Wechaty initPuppet() 
16:50:35 VERB Wechaty initPuppetResolver(undefined)
16:50:35 INFO Wechaty initPuppet() using puppet: puppeteer
16:50:35 VERB MemoryCard sub(puppeteer)
16:50:35 VERB MemoryCard static sub(MemoryCard<default>, puppeteer)
16:50:35 VERB MemoryCard constructor(default)
16:50:35 VERB PuppetConfig puppetResolver(puppeteer)
16:50:36 VERB Puppet constructor({}) #0
16:50:36 VERB StateSwitch constructor(name=PuppetPuppeteer)
16:50:36 VERB MemoryCard constructor()
16:50:36 VERB Puppet constructor() watchdog timeout set to 60 seconds
16:50:36 VERB HotImport callerResolve(., /path/to/node_modules/wechaty-puppet/dist/src/puppet.js)
16:50:36 VERB Puppet constructor() childClassPath=/path/to/node_modules/wechaty-puppet-puppeteer/dist/src
16:50:36 VERB PuppetPuppeteerBridge constructor()
16:50:36 VERB StateSwitch constructor(name=PuppetPuppeteerBridge)
16:50:36 VERB PuppetPuppeteer initWatchdogForScan()
16:50:36 VERB Puppet setMemory()
16:50:36 VERB Wechaty initPuppetVersionSatisfy(Puppet#0<PuppetPuppeteer>(default))
16:50:36 VERB Wechaty initPuppetSemverSatisfy(*)
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(login) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(logout) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(message) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(scan) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(dong) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(error) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(reset) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(start) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(stop) registered
16:50:36 VERB Wechaty initPuppetEventBridge() puppet.on(watchdog) registered
16:50:36 VERB Wechaty initAccessory(Puppet#0<PuppetPuppeteer>(default))
16:50:36 VERB PuppetPuppeteer start() with default
16:50:36 VERB StateSwitch <PuppetPuppeteer> on(pending) <- (false)
16:50:36 VERB PuppetPuppeteer initBridge()
16:50:36 VERB PuppetPuppeteerBridge start()
16:50:36 VERB StateSwitch <PuppetPuppeteerBridge> on(pending) <- (false)
16:50:36 VERB PuppetPuppeteerBridge initBrowser()
16:50:36 VERB PuppetPuppeteerBridge initBrowser() version: HeadlessChrome/69.0.3452.0
16:50:36 VERB PuppetPuppeteerBridge start() initBrowser() done
16:50:36 VERB PuppetPuppeteerBridge initPage()
16:50:36 VERB MemoryCard <puppeteer> get(PUPPET_PUPPETEER)
16:50:36 VERB PuppetPuppeteerBridge cookieDomain(undefined)
16:50:36 VERB PuppetPuppeteerBridge initPage() before page.goto(url)
16:50:42 VERB PuppetPuppeteerBridge initPage() after page.goto(url)
16:50:44 VERB PuppetPuppeteerBridge onLoad() page.url=https://wx.qq.com/
16:50:44 VERB PuppetPuppeteerBridge readyAngular()
16:50:44 VERB PuppetPuppeteerBridge inject()
16:50:44 VERB PuppetPuppeteerBridge ding(ding() OK!)
16:50:44 VERB PuppetPuppeteerBridge clickSwitchAccount()
16:50:44 VERB StateSwitch <PuppetPuppeteerBridge> on(true) <- (pending)
16:50:44 VERB PuppetPuppeteerBridge start() initPage() done
16:50:44 VERB PuppetPuppeteer initBridge() done
16:50:44 VERB StateSwitch <PuppetPuppeteer> on(true) <- (pending)
16:50:44 VERB PuppetPuppeteer start() done
16:50:44 VERB Wechaty on(heartbeat, function) registered
16:50:44 VERB Wechaty onFunction(heartbeat)
16:50:44 VERB StateSwitch <Wechaty> on(true) <- (pending)
16:50:45 VERB PuppetPuppeteerEvent onScan({code: 0, url: https://login.weixin.qq.com/qrcode/gZo5yBqgCA==})
16:50:45 VERB MemoryCard <puppeteer> set(PUPPET_PUPPETEER, [object Object],[object Object],[object Object])
16:50:45 VERB MemoryCard <puppeteer> save() file: /path/to/monster/default.memory-card.json
16:50:45 VERB MemoryCard <> save() file: /path/to/monster/default.memory-card.json
16:50:45 VERB Wechaty start() throttleQueue.subscribe() new item: [object Object]
@huan
Copy link
Member

huan commented Jul 16, 2018

The problem before is:

(node:18008) UnhandledPromiseRejectionWarning: /home/zixia/chatie/wechaty-getting-started/examples/advanced/hot-import-bot/listeners/on-friend.js:19
export default async function onFriend (contact, request) {
^^^^^^

Which is caused that the node v10 still not supports the ES6 import syntax of export default xxx.

We have to use module.exports = xxx to make node happy.

This example should work without any problem in our wechaty-getting-started repo at https://github.com/Chatie/wechaty-getting-started/tree/b382c1067b5968d07c70a8bcbf03858620dfb52f/examples/advanced/hot-import-bot

Please try it and let me know if it works.

BTW: I'll close this issue and move it to wechaty/getting-started#37

@huan huan added the duplicate label Jul 16, 2018
@huan huan closed this as completed Jul 16, 2018
@suntong
Copy link
Contributor Author

suntong commented Jul 16, 2018

Thanks a lot for providing the pure JS code for it!

@huan
Copy link
Member

huan commented Jul 17, 2018

You are welcome.

After I converted to the pure JS code, I can not agree anymore with you to provide pure JS code is very necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants