Closed
Description
Provide Your Network Information
- Beijing,China
- Macbook
Run npm run doctor
or wechaty run doctor
(for docker user), paste output here
**when running "docker run -ti --rm --volume="$(pwd)":/bot zixia/wechaty tuling.js'
report the following error, who can help me? thanks in advance**
_WECHATY Environment Variables: 1
WECHATY_DOCKER=1
Starting Docker Container for Wechaty v0.19.123 with Node.js v10.8.0 ...
Working directory: /bot
Executing babel-node --presets @babel/env tuling.js
/wechaty/node_modules/@babel/core/lib/config/files/plugins.js:152
throw e;
^
Error: Cannot find module 'babel-plugin-transform-runtime' from '/bot'
at Function.module.exports [as sync] (/wechaty/node_modules/resolve/lib/sync.js:43:15)
at resolveStandardizedName (/wechaty/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
at resolvePlugin (/wechaty/node_modules/@babel/core/lib/config/files/plugins.js:54:10)
at loadPlugin (/wechaty/node_modules/@babel/core/lib/config/files/plugins.js:62:20)
at createDescriptor (/wechaty/node_modules/@babel/core/lib/config/config-descriptors.js:114:9)
at items.map (/wechaty/node_modules/@babel/core/lib/config/config-descriptors.js:69:50)
at Array.map (<anonymous>)
at createDescriptors (/wechaty/node_modules/@babel/core/lib/config/config-descriptors.js:69:29)
at createPluginDescriptors (/wechaty/node_modules/@babel/core/lib/config/config-descriptors.js:65:10)
at plugins (/wechaty/node_modules/@babel/core/lib/config/config-descriptors.js:36:19)_
____ _ _ ____ ____ _____ ____ ___ ____ _____
| __ )| | | |/ ___| | _ \| ____| _ \ / _ \| _ \_ _|
| _ \| | | | | _ | |_) | _| | |_) | | | | |_) || |
| |_) | |_| | |_| | | _ <| |___| __/| |_| | _ < | |
|____/ \___/ \____| |_| \_\_____|_| \___/|_| \_\|_|
Press ENTER to continue ...
### 1. source code of tuling.js
const qrTerm = require('qrcode-terminal')
const Tuling123 = require('tuling123-client')
const {
Wechaty,
Message,
} = require('wechaty')
const welcome = `
=============== Powered by Wechaty ===============
-------- https://github.com/Chatie/wechaty --------
I can talk with you using Tuling123.com
Apply your own tuling123.com API_KEY
at: http://www.tuling123.com/html/doc/api.html
__________________________________________________
Please wait... I'm trying to login in...
`
console.log(welcome)
/**
*
* Apply Your Own Tuling123 Developer API_KEY at:
* http://www.tuling123.com
*
*/
const TULING123_API_KEY = '2d04e14137774829822950ae39025faa'
const tuling = new Tuling123(TULING123_API_KEY)
const bot = new Wechaty()
bot.on('scan', onScan)
bot.on('login', onLogin)
bot.on('logout', onLogout)
bot.on('message', onMessage)
bot.on('error', onError)
bot.start()
.catch(console.error)
function onScan (qrcode, status) {
qrTerm.generate(qrcode, { small: true }) // show qrcode on console
}
function onLogin (user) {
console.log(`${user} login`)
}
function onLogout (user) {
console.log(`${user} logout`)
}
function onError (e) {
console.error(e)
}
async function onMessage (msg) {
// Skip message from self, or inside a room
if (msg.self() || msg.room() || msg.from().name() === '微信团队' || msg.type() !== Message.Type.Text) return
console.log('Bot', 'talk: %s' , msg.text())
try {
const {text: reply} = await tuling.ask(msg.text(), {userid: msg.from()})
console.log('Tuling123', 'Talker reply:"%s" for "%s" ',
reply,
msg.text(),
)
await msg.say(reply)
} catch (e) {
console.error('Bot', 'on message tuling.ask() exception: %s' , e && e.message || e)
}
}
Metadata
Metadata
Assignees
Labels
No labels