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

doc typo fix & code clean

上级 5cb8afd4
......@@ -37,7 +37,7 @@ Thanks.
## Voice of the Developer
> @GasLin : it may be the best wecaht sdk i have seen in github! [link](https://github.com/wechaty/wechaty/issues/8#issuecomment-228971491)
> @JasLin : it may be the best wecaht sdk i have seen in github! [link](https://github.com/wechaty/wechaty/issues/8#issuecomment-228971491)
> @Jarvis : 目前用过的最好的微信开发库 [link](http://weibo.com/3296245513/Ec4iNp9Ld?type=comment)
......@@ -546,10 +546,10 @@ message.set('content', 'Hello, World!')
## Contact Class
### Contact.name(): string
`Contact` is `Sayable`
### Contact.name(): string
### Contact.ready(): Contact
A Contact may be not fully initialized yet. Call `ready()` to confirm we get all the data needed.
......@@ -586,9 +586,10 @@ contact.get('name')
## Class Room
Doc is cheap, show you code: [Example/Room-Bot](https://github.com/wechaty/wechaty/blob/master/example/room-bot.js)
`Room` is `Sayable`
Doc is cheap, show you code: [Example/Room-Bot](https://github.com/wechaty/wechaty/blob/master/example/room-bot.js)
### Room.say(content: string, replyTo: Contact|Contact[]): Promise<void>
say `content` inside Room.
......@@ -837,7 +838,7 @@ Github Issue <https://github.com/wechaty/wechaty/issues>
# Contributing
* Lint: eslint
```bash
$ npm lint
$ npm run lint
```
* Create an issue, fork, then send a pull request(with unit test please).
......
......@@ -50,26 +50,19 @@ bot
console.log(`${url}\n[${code}] Scan QR Code in above url to login: `)
})
.on('message', m => {
m.ready()
.then(msg => {
const room = m.room()
const from = m.from()
console.log((room ? '[' + room.topic() + ']' : '')
+ '<' + from.name() + '>'
try {
console.log((m.room() ? '[' + m.room().topic() + ']' : '')
+ '<' + m.from().name() + '>'
+ ':' + m.toStringDigest()
)
// log.info('Bot', 'recv: %s', msg.toStringEx())
// logToFile(JSON.stringify(msg.rawObj))
if (/^(ding|ping|bing)$/i.test(m.get('content')) && !bot.self(m)) {
bot.reply(m, 'dong')
.then(() => { log.warn('Bot', 'REPLY: dong') })
m.say('dong')
log.info('Bot', 'REPLY: dong')
}
})
.catch(e => log.error('Bot', 'ready: %s' , e))
} catch (e) {
log.error('Bot', 'on(message) exception: %s' , e)
}
})
bot.init()
......
......@@ -21,7 +21,7 @@ import {
} from '../config'
import Contact from '../contact'
import {
Message
Message
, MediaMessage
} from '../message'
import log from '../brolog-env'
......@@ -31,7 +31,7 @@ import PuppetWeb from './puppet-web'
/* tslint:disable:variable-name */
const PuppetWebEvent = {
onBrowserDead
onBrowserDead
, onServerLogin
, onServerLogout
......
......@@ -13,10 +13,6 @@
* Class PuppetWeb
*
*/
// const util = require('util')
// const fs = require('fs')
// const co = require('co')
import {
// Config
ScanInfo
......
......@@ -14,7 +14,6 @@ import Config from './config'
import Contact from './contact'
import Message from './message'
import UtilLib from './util-lib'
// import EventScope from './event-scope'
import log from './brolog-env'
......@@ -54,12 +53,6 @@ export class Room extends EventEmitter {
constructor(public id: string) {
super()
log.silly('Room', `constructor(${id})`)
// this.id = id
// this.obj = {}
// this.dirtyObj = {}
// if (!Config.puppetInstance()) {
// throw new Error('Config.puppetInstance() not found')
// }
}
public toString() { return this.id }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册