diff --git a/docs/index.md b/docs/index.md index 271ee62e84b0f52a07fbe52767ee7a83ced2b31b..1b090442cd13b583e6a9305255489e1d832149f4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,46 @@ +## Classes + +
Wechaty: Wechat for ChatBots. +Connect ChatBots
+Class Wechaty
+Licenst: ISC +https://github.com/zixia/wechaty
+Example
+// The World's Shortest ChatBot Code: 6 lines of JavaScript
+const { Wechaty } = require('wechaty')
+
+Wechaty.instance() // Singleton
+.on('scan', (url, code) => console.log(`Scan QR Code to login: ${code}\n${url}`))
+.on('login', user => console.log(`User ${user} logined`))
+.on('message', message => console.log(`Message: ${message}`))
+.init()
+
+wechaty: Wechat for Bot. and for human who talk to bot/robot
+Licenst: ISC +https://github.com/zixia/wechaty
+Add/Del/Topic: https://github.com/wechaty/wechaty/issues/32
+Class Contact +blabla... +IMPORTANT
+Wechaty: Wechaty - Wechat for Bot. Connecting ChatBots
+Licenst: ISC +https://github.com/wechaty/wechaty
+string
- * ~~[.user()](#Wechaty+user) ⇒ Contact
~~
+ * ~~[.user()](#Wechaty+user) ⇒ [Contact](#Contact)
~~
* [.init()](#Wechaty+init)
* [.on()](#Wechaty+on)
* [.quit()](#Wechaty+quit)
* [.logout()](#Wechaty+logout)
- * [.self()](#Wechaty+self) ⇒ Contact
+ * [.self()](#Wechaty+self) ⇒ [Contact](#Contact)
* [.send()](#Wechaty+send)
* [.say()](#Wechaty+say)
* [.sleep()](#Wechaty+sleep)
@@ -62,7 +105,7 @@ console.log(Wechaty.instance().version())
```
-### ~~wechaty.user() ⇒ Contact
~~
+### ~~wechaty.user() ⇒ [Contact](#Contact)
~~
***Deprecated***
**Kind**: instance method of [Wechaty](#Wechaty)
@@ -104,11 +147,11 @@ console.log(Wechaty.instance().version())
-### wechaty.self() ⇒ Contact
+### wechaty.self() ⇒ [Contact](#Contact)
get current user
**Kind**: instance method of [Wechaty](#Wechaty)
-**Returns**: Contact
- current logined user
+**Returns**: [Contact](#Contact)
- current logined user
### wechaty.send()
@@ -139,3 +182,73 @@ get current user
get the singleton instance of Wechaty
**Kind**: static method of [Wechaty](#Wechaty)
+
+
+## Room
+wechaty: Wechat for Bot. and for human who talk to bot/robot
+
+Licenst: ISC
+https://github.com/zixia/wechaty
+
+Add/Del/Topic: https://github.com/wechaty/wechaty/issues/32
+
+**Kind**: global class
+
+
+### Room.load()
+**Kind**: static method of [Room](#Room)
+**Todo**
+
+- [ ] document me
+
+
+
+## Contact
+Class Contact
+blabla...
+**IMPORTANT**
+
+**Kind**: global class
+
+* [Contact](#Contact)
+ * _instance_
+ * [.gender()](#Contact+gender) ⇒
+ * [.avatar()](#Contact+avatar)
+ * _static_
+ * [.findAll()](#Contact.findAll)
+ * [.find()](#Contact.find)
+
+
+
+### contact.gender() ⇒
+Contact gender
+
+**Kind**: instance method of [Contact](#Contact)
+**Returns**: Gender.Male(2) | Gender.Female(1) | Gender.Unknown(0)
+
+
+### contact.avatar()
+Get avatar picture file stream
+
+**Kind**: instance method of [Contact](#Contact)
+
+
+### Contact.findAll()
+find contact by `name` or `alias`
+
+**Kind**: static method of [Contact](#Contact)
+
+
+### Contact.find()
+try to find a contact by filter: {name: string | RegExp}
+
+**Kind**: static method of [Contact](#Contact)
+
+
+## config_1
+Wechaty: * * Wechaty - Wechat for Bot. Connecting ChatBots
+
+Licenst: ISC
+https://github.com/wechaty/wechaty
+
+**Kind**: global constant
diff --git a/package.json b/package.json
index 901a050021678fea36fe24a4b478f61103712790..e13762a50f565b7d1946af877da1a1f030e9f367 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"ava": "ava --verbose --extension ts",
"ts-node": "ts-node",
"dist": "npm run clean && tsc && shx cp package.json dist/ && shx cp src/puppet-web/*.js dist/src/puppet-web/",
- "doc": "npm run dist && jsdoc2md dist/src/wechaty.js > docs/index.md",
+ "doc": "npm run dist && jsdoc2md dist/src/{wechaty,room,contact,friend-request,message}.js > docs/index.md",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"changelog": "github_changelog_generator -u wechaty -p wechaty && sed -i /greenkeeper/d CHANGELOG.md",
"doctor": "npm run check-node-version && ts-node bin/doctor",
diff --git a/src/contact.ts b/src/contact.ts
index bdec798a597e6c5779f71e153c48ed36ed752bcb..a67727ff3de9b77b408cd8def4e920e93d80a403 100644
--- a/src/contact.ts
+++ b/src/contact.ts
@@ -1,11 +1,3 @@
-/**
- *
- * wechaty: Wechat for Bot. and for human who talk to bot/robot
- *
- * Licenst: ISC
- * https://github.com/zixia/wechaty
- *
- */
import {
Config
, Sayable
@@ -61,6 +53,12 @@ export type ContactQueryFilter = {
remark?: string | RegExp
}
+/**
+ * Class Contact
+ * blabla...
+ * **IMPORTANT**
+ *
+ */
export class Contact implements Sayable {
private static pool = new Map