getting-started
getting-started copied to clipboard
This hot-reload example will not work on the second bot if it is launched asynchronically
const { Wechaty } = require('wechaty')
function setupBot(id) {
const bot = new Wechaty({ profile: `memory-cards/${id}` })
bot
.on('scan', './on-scan')
.start()
return bot
}
setInterval(async () => {
setupBot(Math.random())
}, 10000)
We are working on launching bot dynamically. However, whenever we are using hot-reload, any bot launched after the first one will fail. This example will work if we are not using hot-reload.
Error: ERR Wechaty onModulePath(scan, ./on-scan) listener exception: TypeError: Cannot read property 'apply' of undefined
Thanks for point out this with code.
I'll look into it when I get time.