提交 5c257049 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

add node-cleanup to trap bot code exit

上级 e3ea3f14
......@@ -27,6 +27,8 @@ Wechaty is a Bot Framework for Wechat **Personal** Account which can help you cr
> @naishstar: thanks for great SDK [link](https://github.com/wechaty/wechaty/issues/57)
> @shevyan: 简单的接口...和Docker化的封装,结合Docker绝对是一个不错的选择 [link](http://mp.weixin.qq.com/s/o-4VMcAMz0K8yJVdNaUXow)
# Example
The shortest wechat bot code in the world: 6 lines JavaScript
......
......@@ -8,7 +8,8 @@
*/
/* tslint:disable:variable-name */
const QrcodeTerminal = require('qrcode-terminal')
const QrcodeTerminal = require('qrcode-terminal')
const nodeCleanup = require('node-cleanup')
import {
Wechaty
......@@ -77,6 +78,10 @@ bot.init()
process.exit(-1)
})
nodeCleanup(() => {
bot.say('quit')
})
function logToFile(data) {
require('fs').appendFile('message.log', data + '\n\n#############################\n\n', err => {
if (err) { log.error('LogToFile: %s', err) }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册