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

fix contact id null exception for example bot ding-dong-bot #123

上级 a468db15
......@@ -27,9 +27,9 @@ 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)
> @shevyan: 简单的接口...和Docker化的封装...绝对是一个不错的选择 [link](http://mp.weixin.qq.com/s/o-4VMcAMz0K8yJVdNaUXow)
> @lijiarui: [Chat实录|李佳芮:向前一步的程序媛](http://mp.weixin.qq.com/s/dWHAj8XtiKG-1fIS5Og79g)
> @lijiarui: Chat实录|李佳芮:向前一步的程序媛 [link](http://mp.weixin.qq.com/s/dWHAj8XtiKG-1fIS5Og79g)
# Example
......@@ -204,7 +204,7 @@ Scan the following QR Code in WeChat, with secret code _wechaty_, you can join o
![Wechaty Developers' Home](https://raw.githubusercontent.com/wechaty/wechaty/master/image/BotQrcode.png)
Scan now, then you can chat with other Wechaty developers!
Scan now, then you can chat with other Wechaty developers! (secret code: _wechaty_)
# See Also
......
......@@ -44,7 +44,10 @@ console.log(welcome)
const bot = Wechaty.instance({ profile: Config.DEFAULT_PROFILE })
bot
.on('login' , user => log.info('Bot', `${user.name()} logined`))
.on('login' , user => {
log.info('Bot', `${user.name()} logined`)
bot.say('Wechaty login')
})
.on('logout' , user => log.info('Bot', `${user.name()} logouted`))
.on('error' , e => log.info('Bot', 'error: %s', e))
.on('scan', (url, code) => {
......@@ -72,9 +75,6 @@ bot
})
bot.init()
.then(() => {
bot.say('Wechaty init')
})
.catch(e => {
log.error('Bot', 'init() fail: %s', e)
bot.quit()
......
......@@ -127,7 +127,10 @@ export class Bridge {
log.verbose('PuppetWebBridge', 'getUserName()')
try {
return await this.proxyWechaty('getUserName')
const userName = await this.proxyWechaty('getUserName')
return userName
} catch (e) {
log.error('PuppetWebBridge', 'getUserName() exception: %s', e.message)
throw e
......
......@@ -330,6 +330,10 @@ export class PuppetWeb extends Puppet {
* send to `filehelper` for notice / log
*/
public async say(content: string): Promise<void> {
if (!this.logined()) {
throw new Error('can not say before login')
}
const m = new Message()
m.to('filehelper')
m.content(content)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册