From a9a44cea5cf26a19b62da64cc3f65650aef951c0 Mon Sep 17 00:00:00 2001 From: Jiarui LI Date: Fri, 13 Jul 2018 16:34:05 +0800 Subject: [PATCH] regenerate as https://github.com/Chatie/wechaty/issues/1475 --- docs/api/README.md | 8 +- docs/api/contact.md | 10 +- docs/api/friendship.md | 6 +- docs/api/message.md | 10 +- docs/api/room.md | 10 +- docs/api/wechaty.md | 30 ++-- docs/zh/api/README.md | 8 +- docs/zh/api/contact.md | 10 +- docs/zh/api/friendship.md | 6 +- docs/zh/api/message.md | 10 +- docs/zh/api/room.md | 10 +- docs/zh/api/wechaty.md | 30 ++-- gen_api_from_remote.sh | 6 - index.md | 323 +++++--------------------------------- src/api/README.md | 8 +- src/api/contact.md | 10 +- src/api/friendship.md | 6 +- src/api/message.md | 10 +- src/api/room.md | 10 +- src/api/wechaty.md | 30 ++-- src/zh_api/README.md | 8 +- src/zh_api/contact.md | 10 +- src/zh_api/friendship.md | 6 +- src/zh_api/message.md | 10 +- src/zh_api/room.md | 10 +- src/zh_api/wechaty.md | 30 ++-- 26 files changed, 186 insertions(+), 439 deletions(-) delete mode 100755 gen_api_from_remote.sh diff --git a/docs/api/README.md b/docs/api/README.md index c88e014..214e06e 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -27,11 +27,11 @@ If you want to know how to get contact, see [Contact](/api/contact)

[Room](/api/room)

All wechat rooms(groups) will be encapsulated as a Room.

-

Examples/Room-Bot

+

Examples/Room-Bot

[Contact](/api/contact)

All wechat contacts(friend) will be encapsulated as a Contact.

-

Examples/Contact-Bot

+

Examples/Contact-Bot

[Friendship](/api/friendship)

Send, receive friend request, and friend confirmation events.

@@ -40,11 +40,11 @@ If you want to know how to get contact, see [Contact](/api/contact)

  • receive request(in friend event)
  • confirmation friendship(friend event)
  • -

    Examples/Friend-Bot

    +

    Examples/Friend-Bot

    [Message](/api/message)

    All wechat messages will be encapsulated as a Message.

    -

    Examples/Ding-Dong-Bot

    +

    Examples/Ding-Dong-Bot

    diff --git a/docs/api/contact.md b/docs/api/contact.md index 2fde941..a972313 100644 --- a/docs/api/contact.md +++ b/docs/api/contact.md @@ -1,7 +1,7 @@ # Contact All wechat contacts(friend) will be encapsulated as a Contact. -[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/master/examples/contact-bot.ts) +[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/contact-bot.ts) **Kind**: global class @@ -46,11 +46,11 @@ const bot = new Wechaty() await bot.start() const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of your contact name in wechat -# 1. send text to contact +// 1. send text to contact await contact.say('welcome to wechaty!') -# 2. send media file to contact +// 2. send media file to contact import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') @@ -58,7 +58,7 @@ const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await contact.say(fileBox1) await contact.say(fileBox2) -# 3. send contact card to contact +// 3. send contact card to contact const contactCard = bot.Contact.load('contactId') await contact.say(contactCard) @@ -234,7 +234,7 @@ Get avatar picture file stream **Kind**: instance method of [Contact](/api/contact) **Example** ```js -# Save avatar to local file like `1-name.jpg` +// Save avatar to local file like `1-name.jpg` const file = await contact.avatar() const name = file.name diff --git a/docs/api/friendship.md b/docs/api/friendship.md index f168202..a1c67ea 100644 --- a/docs/api/friendship.md +++ b/docs/api/friendship.md @@ -5,7 +5,7 @@ Send, receive friend request, and friend confirmation events. 2. receive request(in friend event) 3. confirmation friendship(friend event) -[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/master/examples/friend-bot.ts) +[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/friend-bot.ts) **Kind**: global class @@ -37,13 +37,13 @@ bot.on('friendship', async friendship => { console.log(`received friend event.`) switch (friendship.type()) { - # 1. New Friend Request + // 1. New Friend Request case Friendship.Type.Receive: await friendship.accept() break - # 2. Friend Ship Confirmed + // 2. Friend Ship Confirmed case Friendship.Type.Confirm: console.log(`friend ship confirmed`) diff --git a/docs/api/message.md b/docs/api/message.md index dc957d4..53cd5f3 100644 --- a/docs/api/message.md +++ b/docs/api/message.md @@ -1,7 +1,7 @@ # Message All wechat messages will be encapsulated as a Message. -[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) **Kind**: global class @@ -133,7 +133,7 @@ bot Reply a Text or Media File message to the sender. **Kind**: instance method of [Message](/api/message) -**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) | Param | Type | Description | | --- | --- | --- | @@ -147,20 +147,20 @@ const bot = new Wechaty() bot .on('message', async m => { -# 1. send Image +// 1. send Image if (/^ding$/i.test(m.text())) { const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await msg.say(fileBox) } -# 2. send Text +// 2. send Text if (/^dong$/i.test(m.text())) { await msg.say('dingdingding') } -# 3. send Contact +// 3. send Contact if (/^lijiarui$/i.test(m.text())) { const contactCard = await bot.Contact.find({name: 'lijiarui'}) diff --git a/docs/api/room.md b/docs/api/room.md index 421aff1..33724ae 100644 --- a/docs/api/room.md +++ b/docs/api/room.md @@ -1,7 +1,7 @@ # Room All wechat rooms(groups) will be encapsulated as a Room. -[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/master/examples/room-bot.ts) +[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/room-bot.ts) **Kind**: global class @@ -52,22 +52,22 @@ await bot.start() // after logged in... const room = await bot.Room.find({topic: 'wechaty'}) -# 1. Send text inside Room +// 1. Send text inside Room await room.say('Hello world!') -# 2. Send media file inside Room +// 2. Send media file inside Room import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await room.say(fileBox1) await room.say(fileBox2) -# 3. Send Contact Card in a room +// 3. Send Contact Card in a room const contactCard = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say(contactCard) -# 4. Send text inside room and mention @mention contact +// 4. Send text inside room and mention @mention contact const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say('Hello world!', contact) ``` diff --git a/docs/api/wechaty.md b/docs/api/wechaty.md index 1976c0b..4e25591 100644 --- a/docs/api/wechaty.md +++ b/docs/api/wechaty.md @@ -27,7 +27,7 @@ See more: * [.logout()](#Wechatylogout) Promise.<void> * [.logonoff()](#Wechatylogonoff) boolean * ~~[.self()](#Wechatyself)~~ - * [.userSelf()](#WechatyuserSelf) [Contact](/api/contact) + * [.userSelf()](#WechatyuserSelf) ContactSelf * [.say(textOrContactOrFile)](#Wechatysay) Promise.<void> * [.version([forceNpm])](#Wechatyversion) string * _static_ @@ -81,7 +81,7 @@ see advanced [chaining usage](https://github.com/Chatie/wechaty-getting-started/ **Example** *(Event:scan)* ```js -# Scan Event will emit when the bot needs to show you a QR Code for scanning +// Scan Event will emit when the bot needs to show you a QR Code for scanning bot.on('scan', (url: string, code: number) => { console.log(`[${code}] Scan ${url} to login.` ) @@ -89,7 +89,7 @@ bot.on('scan', (url: string, code: number) => { ``` **Example** *(Event:login )* ```js -# Login Event will emit when bot login full successful. +// Login Event will emit when bot login full successful. bot.on('login', (user: ContactSelf) => { console.log(`user ${user} login`) @@ -97,7 +97,7 @@ bot.on('login', (user: ContactSelf) => { ``` **Example** *(Event:logout )* ```js -# Logout Event will emit when bot detected log out. +// Logout Event will emit when bot detected log out. bot.on('logout', (user: ContactSelf) => { console.log(`user ${user} logout`) @@ -105,7 +105,7 @@ bot.on('logout', (user: ContactSelf) => { ``` **Example** *(Event:message )* ```js -# Message Event will emit when there's a new message. +// Message Event will emit when there's a new message. wechaty.on('message', (message: Message) => { console.log(`message ${message} received`) @@ -113,7 +113,7 @@ wechaty.on('message', (message: Message) => { ``` **Example** *(Event:friendship )* ```js -# Friendship Event will emit when got a new friend request, or friendship is confirmed. +// Friendship Event will emit when got a new friend request, or friendship is confirmed. bot.on('friendship', (friendship: Friendship) => { if(friendship.type() === Friendship.Type.RECEIVE){ // 1. receive new friendship request from new contact @@ -131,7 +131,7 @@ bot.on('friendship', (friendship: Friendship) => { ``` **Example** *(Event:room-join )* ```js -# room-join Event will emit when someone join the room. +// room-join Event will emit when someone join the room. bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { const nameList = inviteeList.map(c => c.name()).join(',') @@ -140,7 +140,7 @@ bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { ``` **Example** *(Event:room-leave )* ```js -# room-leave Event will emit when someone leave the room. +// room-leave Event will emit when someone leave the room. bot.on('room-leave', (room: Room, leaverList: Contact[]) => { const nameList = leaverList.map(c => c.name()).join(',') @@ -149,7 +149,7 @@ bot.on('room-leave', (room: Room, leaverList: Contact[]) => { ``` **Example** *(Event:room-topic )* ```js -# room-topic Event will emit when someone change the room's topic. +// room-topic Event will emit when someone change the room's topic. bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Contact) => { console.log(`Room ${room.topic()} topic changed from ${oldTopic} to ${topic} by ${changer.name()}`) @@ -157,7 +157,7 @@ bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Cont ``` **Example** *(Event:error )* ```js -# error Event will emit when there's an error occurred. +// error Event will emit when there's an error occurred. bot.on('error', (error) => { console.error(error) @@ -245,7 +245,7 @@ Should use [userSelf](#WechatyuserSelf) instead ## wechaty.userSelf() -**Return the type of**: [Contact](/api/contact) +**Return the type of**: ContactSelf Get current user @@ -277,19 +277,19 @@ const bot = new Wechaty() await bot.start() // after logged in -# 1. send text to bot itself +// 1. send text to bot itself await bot.say('hello!') -# 2. send Contact to bot itself +// 2. send Contact to bot itself const contact = bot.Contact.load('contactId') await bot.say(contact) -# 3. send Image to bot itself from remote url +// 3. send Image to bot itself from remote url import { FileBox } from 'file-box' const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await bot.say(fileBox) -# 4. send Image to bot itself from local file +// 4. send Image to bot itself from local file import { FileBox } from 'file-box' const fileBox = FileBox.fromLocal('/tmp/text.jpg') await bot.say(fileBox) diff --git a/docs/zh/api/README.md b/docs/zh/api/README.md index 0ddac42..57b3c35 100644 --- a/docs/zh/api/README.md +++ b/docs/zh/api/README.md @@ -27,11 +27,11 @@ If you want to know how to get contact, see [Contact](/zh/api/contact)

    [Room](/zh/api/room)

    All wechat rooms(groups) will be encapsulated as a Room.

    -

    Examples/Room-Bot

    +

    Examples/Room-Bot

    [Contact](/zh/api/contact)

    All wechat contacts(friend) will be encapsulated as a Contact.

    -

    Examples/Contact-Bot

    +

    Examples/Contact-Bot

    [Friendship](/zh/api/friendship)

    Send, receive friend request, and friend confirmation events.

    @@ -40,11 +40,11 @@ If you want to know how to get contact, see [Contact](/zh/api/contact)

  • receive request(in friend event)
  • confirmation friendship(friend event)
  • -

    Examples/Friend-Bot

    +

    Examples/Friend-Bot

    [Message](/zh/api/message)

    All wechat messages will be encapsulated as a Message.

    -

    Examples/Ding-Dong-Bot

    +

    Examples/Ding-Dong-Bot

    diff --git a/docs/zh/api/contact.md b/docs/zh/api/contact.md index 18675ec..bf4c7a8 100644 --- a/docs/zh/api/contact.md +++ b/docs/zh/api/contact.md @@ -1,7 +1,7 @@ # Contact类 All wechat contacts(friend) will be encapsulated as a Contact. -[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/master/examples/contact-bot.ts) +[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/contact-bot.ts) **Kind**: global class @@ -46,11 +46,11 @@ const bot = new Wechaty() await bot.start() const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of your contact name in wechat -# 1. send text to contact +// 1. send text to contact await contact.say('welcome to wechaty!') -# 2. send media file to contact +// 2. send media file to contact import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') @@ -58,7 +58,7 @@ const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await contact.say(fileBox1) await contact.say(fileBox2) -# 3. send contact card to contact +// 3. send contact card to contact const contactCard = bot.Contact.load('contactId') await contact.say(contactCard) @@ -234,7 +234,7 @@ Get avatar picture file stream **Kind**: instance method of [Contact](/zh/api/contact) **Example** ```js -# Save avatar to local file like `1-name.jpg` +// Save avatar to local file like `1-name.jpg` const file = await contact.avatar() const name = file.name diff --git a/docs/zh/api/friendship.md b/docs/zh/api/friendship.md index 8062c1e..dac796a 100644 --- a/docs/zh/api/friendship.md +++ b/docs/zh/api/friendship.md @@ -5,7 +5,7 @@ Send, receive friend request, and friend confirmation events. 2. receive request(in friend event) 3. confirmation friendship(friend event) -[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/master/examples/friend-bot.ts) +[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/friend-bot.ts) **Kind**: global class @@ -37,13 +37,13 @@ bot.on('friendship', async friendship => { console.log(`received friend event.`) switch (friendship.type()) { - # 1. New Friend Request + // 1. New Friend Request case Friendship.Type.Receive: await friendship.accept() break - # 2. Friend Ship Confirmed + // 2. Friend Ship Confirmed case Friendship.Type.Confirm: console.log(`friend ship confirmed`) diff --git a/docs/zh/api/message.md b/docs/zh/api/message.md index 9176fef..24c6485 100644 --- a/docs/zh/api/message.md +++ b/docs/zh/api/message.md @@ -1,7 +1,7 @@ # Message类 All wechat messages will be encapsulated as a Message. -[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) **Kind**: global class @@ -133,7 +133,7 @@ bot Reply a Text or Media File message to the sender. **Kind**: instance method of [Message](/zh/api/message) -**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) | Param | Type | Description | | --- | --- | --- | @@ -147,20 +147,20 @@ const bot = new Wechaty() bot .on('message', async m => { -# 1. send Image +// 1. send Image if (/^ding$/i.test(m.text())) { const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await msg.say(fileBox) } -# 2. send Text +// 2. send Text if (/^dong$/i.test(m.text())) { await msg.say('dingdingding') } -# 3. send Contact +// 3. send Contact if (/^lijiarui$/i.test(m.text())) { const contactCard = await bot.Contact.find({name: 'lijiarui'}) diff --git a/docs/zh/api/room.md b/docs/zh/api/room.md index e0eaa7a..9c774a1 100644 --- a/docs/zh/api/room.md +++ b/docs/zh/api/room.md @@ -1,7 +1,7 @@ # Room类 All wechat rooms(groups) will be encapsulated as a Room. -[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/master/examples/room-bot.ts) +[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/room-bot.ts) **Kind**: global class @@ -52,22 +52,22 @@ await bot.start() // after logged in... const room = await bot.Room.find({topic: 'wechaty'}) -# 1. Send text inside Room +// 1. Send text inside Room await room.say('Hello world!') -# 2. Send media file inside Room +// 2. Send media file inside Room import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await room.say(fileBox1) await room.say(fileBox2) -# 3. Send Contact Card in a room +// 3. Send Contact Card in a room const contactCard = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say(contactCard) -# 4. Send text inside room and mention @mention contact +// 4. Send text inside room and mention @mention contact const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say('Hello world!', contact) ``` diff --git a/docs/zh/api/wechaty.md b/docs/zh/api/wechaty.md index e155b58..93aa8c2 100644 --- a/docs/zh/api/wechaty.md +++ b/docs/zh/api/wechaty.md @@ -27,7 +27,7 @@ See more: * [.logout()](#Wechatylogout) Promise.<void> * [.logonoff()](#Wechatylogonoff) boolean * ~~[.self()](#Wechatyself)~~ - * [.userSelf()](#WechatyuserSelf) [Contact](/zh/api/contact) + * [.userSelf()](#WechatyuserSelf) ContactSelf * [.say(textOrContactOrFile)](#Wechatysay) Promise.<void> * [.version([forceNpm])](#Wechatyversion) string * _static_ @@ -81,7 +81,7 @@ see advanced [chaining usage](https://github.com/Chatie/wechaty-getting-started/ **Example** *(Event:scan)* ```js -# Scan Event will emit when the bot needs to show you a QR Code for scanning +// Scan Event will emit when the bot needs to show you a QR Code for scanning bot.on('scan', (url: string, code: number) => { console.log(`[${code}] Scan ${url} to login.` ) @@ -89,7 +89,7 @@ bot.on('scan', (url: string, code: number) => { ``` **Example** *(Event:login )* ```js -# Login Event will emit when bot login full successful. +// Login Event will emit when bot login full successful. bot.on('login', (user: ContactSelf) => { console.log(`user ${user} login`) @@ -97,7 +97,7 @@ bot.on('login', (user: ContactSelf) => { ``` **Example** *(Event:logout )* ```js -# Logout Event will emit when bot detected log out. +// Logout Event will emit when bot detected log out. bot.on('logout', (user: ContactSelf) => { console.log(`user ${user} logout`) @@ -105,7 +105,7 @@ bot.on('logout', (user: ContactSelf) => { ``` **Example** *(Event:message )* ```js -# Message Event will emit when there's a new message. +// Message Event will emit when there's a new message. wechaty.on('message', (message: Message) => { console.log(`message ${message} received`) @@ -113,7 +113,7 @@ wechaty.on('message', (message: Message) => { ``` **Example** *(Event:friendship )* ```js -# Friendship Event will emit when got a new friend request, or friendship is confirmed. +// Friendship Event will emit when got a new friend request, or friendship is confirmed. bot.on('friendship', (friendship: Friendship) => { if(friendship.type() === Friendship.Type.RECEIVE){ // 1. receive new friendship request from new contact @@ -131,7 +131,7 @@ bot.on('friendship', (friendship: Friendship) => { ``` **Example** *(Event:room-join )* ```js -# room-join Event will emit when someone join the room. +// room-join Event will emit when someone join the room. bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { const nameList = inviteeList.map(c => c.name()).join(',') @@ -140,7 +140,7 @@ bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { ``` **Example** *(Event:room-leave )* ```js -# room-leave Event will emit when someone leave the room. +// room-leave Event will emit when someone leave the room. bot.on('room-leave', (room: Room, leaverList: Contact[]) => { const nameList = leaverList.map(c => c.name()).join(',') @@ -149,7 +149,7 @@ bot.on('room-leave', (room: Room, leaverList: Contact[]) => { ``` **Example** *(Event:room-topic )* ```js -# room-topic Event will emit when someone change the room's topic. +// room-topic Event will emit when someone change the room's topic. bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Contact) => { console.log(`Room ${room.topic()} topic changed from ${oldTopic} to ${topic} by ${changer.name()}`) @@ -157,7 +157,7 @@ bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Cont ``` **Example** *(Event:error )* ```js -# error Event will emit when there's an error occurred. +// error Event will emit when there's an error occurred. bot.on('error', (error) => { console.error(error) @@ -245,7 +245,7 @@ Should use [userSelf](#WechatyuserSelf) instead ## wechaty.userSelf() -**Return the type of**: [Contact](/zh/api/contact) +**Return the type of**: ContactSelf Get current user @@ -277,19 +277,19 @@ const bot = new Wechaty() await bot.start() // after logged in -# 1. send text to bot itself +// 1. send text to bot itself await bot.say('hello!') -# 2. send Contact to bot itself +// 2. send Contact to bot itself const contact = bot.Contact.load('contactId') await bot.say(contact) -# 3. send Image to bot itself from remote url +// 3. send Image to bot itself from remote url import { FileBox } from 'file-box' const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await bot.say(fileBox) -# 4. send Image to bot itself from local file +// 4. send Image to bot itself from local file import { FileBox } from 'file-box' const fileBox = FileBox.fromLocal('/tmp/text.jpg') await bot.say(fileBox) diff --git a/gen_api_from_remote.sh b/gen_api_from_remote.sh deleted file mode 100755 index 9472a3b..0000000 --- a/gen_api_from_remote.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# https://raw.githubusercontent.com/lijiarui/wechaty/add-doc/docs/index.md - -# curl https://raw.githubusercontent.com/lijiarui/wechaty/add-doc/docs/index.md | python3 parse_doc.py -cat /Users/jiaruili/git/rui/wechaty/docs/index.md | python3 parse_doc.py \ No newline at end of file diff --git a/index.md b/index.md index 210b26a..150522f 100644 --- a/index.md +++ b/index.md @@ -1,4 +1,4 @@ -# Wechaty v0.19.4 Documentation +# Wechaty v0.19.10 Documentation * @@ -26,14 +26,12 @@ If you want to know how to get contact, see Contact

    Room

    All wechat rooms(groups) will be encapsulated as a Room.

    -

    Examples/Room-Bot

    +

    Examples/Room-Bot

    Contact

    All wechat contacts(friend) will be encapsulated as a Contact.

    -

    Examples/Contact-Bot

    +

    Examples/Contact-Bot

    -
    ContactSelfContact
    -
    Friendship

    Send, receive friend request, and friend confirmation events.

      @@ -41,11 +39,11 @@ If you want to know how to get contact, see Contact

    1. receive request(in friend event)
    2. confirmation friendship(friend event)
    -

    Examples/Friend-Bot

    +

    Examples/Friend-Bot

    Message

    All wechat messages will be encapsulated as a Message.

    -

    Examples/Ding-Dong-Bot

    +

    Examples/Ding-Dong-Bot

    @@ -116,7 +114,7 @@ See more: * [.logout()](#Wechaty+logout) ⇒ Promise.<void> * [.logonoff()](#Wechaty+logonoff) ⇒ boolean * ~~[.self()](#Wechaty+self)~~ - * [.userSelf()](#Wechaty+userSelf) ⇒ [Contact](#Contact) + * [.userSelf()](#Wechaty+userSelf) ⇒ ContactSelf * [.say(textOrContactOrFile)](#Wechaty+say) ⇒ Promise.<void> * [.version([forceNpm])](#Wechaty+version) ⇒ string * _static_ @@ -166,7 +164,7 @@ see advanced [chaining usage](https://github.com/Chatie/wechaty-getting-started/ **Example** *(Event:scan)* ```js -# Scan Event will emit when the bot needs to show you a QR Code for scanning +// Scan Event will emit when the bot needs to show you a QR Code for scanning bot.on('scan', (url: string, code: number) => { console.log(`[${code}] Scan ${url} to login.` ) @@ -174,7 +172,7 @@ bot.on('scan', (url: string, code: number) => { ``` **Example** *(Event:login )* ```js -# Login Event will emit when bot login full successful. +// Login Event will emit when bot login full successful. bot.on('login', (user: ContactSelf) => { console.log(`user ${user} login`) @@ -182,7 +180,7 @@ bot.on('login', (user: ContactSelf) => { ``` **Example** *(Event:logout )* ```js -# Logout Event will emit when bot detected log out. +// Logout Event will emit when bot detected log out. bot.on('logout', (user: ContactSelf) => { console.log(`user ${user} logout`) @@ -190,7 +188,7 @@ bot.on('logout', (user: ContactSelf) => { ``` **Example** *(Event:message )* ```js -# Message Event will emit when there's a new message. +// Message Event will emit when there's a new message. wechaty.on('message', (message: Message) => { console.log(`message ${message} received`) @@ -198,7 +196,7 @@ wechaty.on('message', (message: Message) => { ``` **Example** *(Event:friendship )* ```js -# Friendship Event will emit when got a new friend request, or friendship is confirmed. +// Friendship Event will emit when got a new friend request, or friendship is confirmed. bot.on('friendship', (friendship: Friendship) => { if(friendship.type() === Friendship.Type.RECEIVE){ // 1. receive new friendship request from new contact @@ -216,7 +214,7 @@ bot.on('friendship', (friendship: Friendship) => { ``` **Example** *(Event:room-join )* ```js -# room-join Event will emit when someone join the room. +// room-join Event will emit when someone join the room. bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { const nameList = inviteeList.map(c => c.name()).join(',') @@ -225,7 +223,7 @@ bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { ``` **Example** *(Event:room-leave )* ```js -# room-leave Event will emit when someone leave the room. +// room-leave Event will emit when someone leave the room. bot.on('room-leave', (room: Room, leaverList: Contact[]) => { const nameList = leaverList.map(c => c.name()).join(',') @@ -234,7 +232,7 @@ bot.on('room-leave', (room: Room, leaverList: Contact[]) => { ``` **Example** *(Event:room-topic )* ```js -# room-topic Event will emit when someone change the room's topic. +// room-topic Event will emit when someone change the room's topic. bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Contact) => { console.log(`Room ${room.topic()} topic changed from ${oldTopic} to ${topic} by ${changer.name()}`) @@ -242,7 +240,7 @@ bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Cont ``` **Example** *(Event:error )* ```js -# error Event will emit when there's an error occurred. +// error Event will emit when there's an error occurred. bot.on('error', (error) => { console.error(error) @@ -312,7 +310,7 @@ Should use [userSelf](#Wechaty+userSelf) instead **Kind**: instance method of [Wechaty](#Wechaty) -### wechaty.userSelf() ⇒ [Contact](#Contact) +### wechaty.userSelf() ⇒ ContactSelf Get current user **Kind**: instance method of [Wechaty](#Wechaty) @@ -338,19 +336,19 @@ const bot = new Wechaty() await bot.start() // after logged in -# 1. send text to bot itself +// 1. send text to bot itself await bot.say('hello!') -# 2. send Contact to bot itself +// 2. send Contact to bot itself const contact = bot.Contact.load('contactId') await bot.say(contact) -# 3. send Image to bot itself from remote url +// 3. send Image to bot itself from remote url import { FileBox } from 'file-box' const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await bot.say(fileBox) -# 4. send Image to bot itself from local file +// 4. send Image to bot itself from local file import { FileBox } from 'file-box' const fileBox = FileBox.fromLocal('/tmp/text.jpg') await bot.say(fileBox) @@ -398,7 +396,7 @@ Wechaty.instance() // Singleton ## Room All wechat rooms(groups) will be encapsulated as a Room. -[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/master/examples/room-bot.ts) +[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/room-bot.ts) **Kind**: global class @@ -445,22 +443,22 @@ await bot.start() // after logged in... const room = await bot.Room.find({topic: 'wechaty'}) -# 1. Send text inside Room +// 1. Send text inside Room await room.say('Hello world!') -# 2. Send media file inside Room +// 2. Send media file inside Room import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await room.say(fileBox1) await room.say(fileBox2) -# 3. Send Contact Card in a room +// 3. Send Contact Card in a room const contactCard = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say(contactCard) -# 4. Send text inside room and mention @mention contact +// 4. Send text inside room and mention @mention contact const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say('Hello world!', contact) ``` @@ -890,7 +888,7 @@ const room = bot.Room.load('roomId') ## Contact All wechat contacts(friend) will be encapsulated as a Contact. -[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/master/examples/contact-bot.ts) +[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/contact-bot.ts) **Kind**: global class @@ -931,11 +929,11 @@ const bot = new Wechaty() await bot.start() const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of your contact name in wechat -# 1. send text to contact +// 1. send text to contact await contact.say('welcome to wechaty!') -# 2. send media file to contact +// 2. send media file to contact import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') @@ -943,7 +941,7 @@ const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await contact.say(fileBox1) await contact.say(fileBox2) -# 3. send contact card to contact +// 3. send contact card to contact const contactCard = bot.Contact.load('contactId') await contact.say(contactCard) @@ -1087,7 +1085,7 @@ Get avatar picture file stream **Kind**: instance method of [Contact](#Contact) **Example** ```js -# Save avatar to local file like `1-name.jpg` +// Save avatar to local file like `1-name.jpg` const file = await contact.avatar() const name = file.name @@ -1186,251 +1184,6 @@ const contactList = await bot.Contact.findAll() // get the co const contactList = await bot.Contact.findAll({name: 'ruirui'}) // find allof the contacts whose name is 'ruirui' const contactList = await bot.Contact.findAll({alias: 'lijiarui'}) // find all of the contacts whose alias is 'lijiarui' ``` - - -## ContactSelf ⇐ [Contact](#Contact) -**Kind**: global class -**Extends**: [Contact](#Contact) - -* [ContactSelf](#ContactSelf) ⇐ [Contact](#Contact) - * [new ContactSelf()](#new_ContactSelf_new) - * [.say(textOrContactOrFile)](#Contact+say) ⇒ Promise.<void> - * [.name()](#Contact+name) ⇒ string - * [.alias(newAlias)](#Contact+alias) ⇒ string \| null \| Promise.<boolean> - * ~~[.stranger()](#Contact+stranger)~~ - * [.friend()](#Contact+friend) ⇒ boolean \| null - * ~~[.official()](#Contact+official)~~ - * ~~[.personal()](#Contact+personal)~~ - * [.type()](#Contact+type) ⇒ ContactType.Unknown \| ContactType.Personal \| ContactType.Official - * [.gender()](#Contact+gender) ⇒ ContactGender.Unknown \| ContactGender.Male \| ContactGender.Female - * [.province()](#Contact+province) ⇒ string \| null - * [.city()](#Contact+city) ⇒ string \| null - * [.avatar()](#Contact+avatar) ⇒ Promise.<FileBox> - * ~~[.refresh()](#Contact+refresh)~~ - * [.sync()](#Contact+sync) ⇒ Promise.<this> - * [.self()](#Contact+self) ⇒ boolean - - - -### new ContactSelf() -Bot itself will be encapsulated as a ContactSelf. - -**Example** -```js -const bot = new Wechaty() -await bot.start() -bot.on('login', (user: ContactSelf) => { - console.log(`user ${user} login`) -}) -``` - - -### contactSelf.say(textOrContactOrFile) ⇒ Promise.<void> -**Kind**: instance method of [ContactSelf](#ContactSelf) - -| Param | Type | Description | -| --- | --- | --- | -| textOrContactOrFile | string \| [Contact](#Contact) \| FileBox | send text, Contact, or file to contact.
    You can use [FileBox](https://www.npmjs.com/package/file-box) to send file | - -**Example** -```js -const bot = new Wechaty() -await bot.start() -const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of your contact name in wechat - -# 1. send text to contact - -await contact.say('welcome to wechaty!') - -# 2. send media file to contact - -import { FileBox } from 'file-box' -const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') -const fileBox2 = FileBox.fromLocal('/tmp/text.txt') -await contact.say(fileBox1) -await contact.say(fileBox2) - -# 3. send contact card to contact - -const contactCard = bot.Contact.load('contactId') -await contact.say(contactCard) -``` - - -### contactSelf.name() ⇒ string -Get the name from a contact - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Example** -```js -const name = contact.name() -``` - - -### contactSelf.alias(newAlias) ⇒ string \| null \| Promise.<boolean> -GET / SET / DELETE the alias for a contact - -Tests show it will failed if set alias too frequently(60 times in one minute). - -**Kind**: instance method of [ContactSelf](#ContactSelf) - -| Param | Type | -| --- | --- | -| newAlias | none \| string \| null | - -**Example** *( GET the alias for a contact, return {(string | null)})* -```js -const alias = contact.alias() -if (alias === null) { - console.log('You have not yet set any alias for contact ' + contact.name()) -} else { - console.log('You have already set an alias for contact ' + contact.name() + ':' + alias) -} -``` -**Example** *(SET the alias for a contact)* -```js -try { - await contact.alias('lijiarui') - console.log(`change ${contact.name()}'s alias successfully!`) -} catch (e) { - console.log(`failed to change ${contact.name()} alias!`) -} -``` -**Example** *(DELETE the alias for a contact)* -```js -try { - const oldAlias = await contact.alias(null) - console.log(`delete ${contact.name()}'s alias successfully!`) - console.log('old alias is ${oldAlias}`) -} catch (e) { - console.log(`failed to delete ${contact.name()}'s alias!`) -} -``` - - -### ~~contactSelf.stranger()~~ -***Deprecated*** - -Should use [friend](#Contact+friend) instead - -**Kind**: instance method of [ContactSelf](#ContactSelf) - - -### contactSelf.friend() ⇒ boolean \| null -Check if contact is friend - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Returns**: boolean \| null -
    True for friend of the bot
    -False for not friend of the bot, null for unknown. -**Example** -```js -const isFriend = contact.friend() -``` - - -### ~~contactSelf.official()~~ -***Deprecated*** - -Check if it's a offical account, should use [type](#Contact+type) instead - -**Kind**: instance method of [ContactSelf](#ContactSelf) - - -### ~~contactSelf.personal()~~ -***Deprecated*** - -Check if it's a personal account, should use [type](#Contact+type) instead - -**Kind**: instance method of [ContactSelf](#ContactSelf) - - -### contactSelf.type() ⇒ ContactType.Unknown \| ContactType.Personal \| ContactType.Official -Return the type of the Contact -> Tips: ContactType is enum here.
    - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Example** -```js -const bot = new Wechaty() -await bot.start() -const isOfficial = contact.type() === bot.Contact.Type.Official -``` - - -### contactSelf.gender() ⇒ ContactGender.Unknown \| ContactGender.Male \| ContactGender.Female -Contact gender -> Tips: ContactGender is enum here.
    - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Example** -```js -const gender = contact.gender() === bot.Contact.Gender.Male -``` - - -### contactSelf.province() ⇒ string \| null -Get the region 'province' from a contact - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Example** -```js -const province = contact.province() -``` - - -### contactSelf.city() ⇒ string \| null -Get the region 'city' from a contact - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Example** -```js -const city = contact.city() -``` - - -### contactSelf.avatar() ⇒ Promise.<FileBox> -Get avatar picture file stream - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Overrides**: [avatar](#Contact+avatar) -**Example** -```js -# Save avatar to local file like `1-name.jpg` - -const file = await contact.avatar() -const name = file.name -await file.toFile(name, true) -console.log(`Contact: ${contact.name()} with avatar file: ${name}`) -``` - - -### ~~contactSelf.refresh()~~ -***Deprecated*** - -Force reload(re-ready()) data for Contact, use [sync](#Contact+sync) instead - -**Kind**: instance method of [ContactSelf](#ContactSelf) - - -### contactSelf.sync() ⇒ Promise.<this> -Force reload(re-ready()) data for Contact, - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Example** -```js -await contact.sync() -``` - - -### contactSelf.self() ⇒ boolean -Check if contact is self - -**Kind**: instance method of [ContactSelf](#ContactSelf) -**Returns**: boolean - True for contact is self, False for contact is others -**Example** -```js -const isSelf = contact.self() -``` ## Friendship @@ -1440,7 +1193,7 @@ Send, receive friend request, and friend confirmation events. 2. receive request(in friend event) 3. confirmation friendship(friend event) -[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/master/examples/friend-bot.ts) +[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/friend-bot.ts) **Kind**: global class @@ -1468,13 +1221,13 @@ bot.on('friendship', async friendship => { console.log(`received friend event.`) switch (friendship.type()) { - # 1. New Friend Request + // 1. New Friend Request case Friendship.Type.Receive: await friendship.accept() break - # 2. Friend Ship Confirmed + // 2. Friend Ship Confirmed case Friendship.Type.Confirm: console.log(`friend ship confirmed`) @@ -1583,7 +1336,7 @@ for (let i = 0; i < memberList.length; i++) { ## Message All wechat messages will be encapsulated as a Message. -[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) **Kind**: global class @@ -1695,7 +1448,7 @@ bot Reply a Text or Media File message to the sender. **Kind**: instance method of [Message](#Message) -**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) | Param | Type | Description | | --- | --- | --- | @@ -1709,20 +1462,20 @@ const bot = new Wechaty() bot .on('message', async m => { -# 1. send Image +// 1. send Image if (/^ding$/i.test(m.text())) { const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await msg.say(fileBox) } -# 2. send Text +// 2. send Text if (/^dong$/i.test(m.text())) { await msg.say('dingdingding') } -# 3. send Contact +// 3. send Contact if (/^lijiarui$/i.test(m.text())) { const contactCard = await bot.Contact.find({name: 'lijiarui'}) diff --git a/src/api/README.md b/src/api/README.md index c88e014..214e06e 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -27,11 +27,11 @@ If you want to know how to get contact, see [Contact](/api/contact)

    [Room](/api/room)

    All wechat rooms(groups) will be encapsulated as a Room.

    -

    Examples/Room-Bot

    +

    Examples/Room-Bot

    [Contact](/api/contact)

    All wechat contacts(friend) will be encapsulated as a Contact.

    -

    Examples/Contact-Bot

    +

    Examples/Contact-Bot

    [Friendship](/api/friendship)

    Send, receive friend request, and friend confirmation events.

    @@ -40,11 +40,11 @@ If you want to know how to get contact, see [Contact](/api/contact)

  • receive request(in friend event)
  • confirmation friendship(friend event)
  • -

    Examples/Friend-Bot

    +

    Examples/Friend-Bot

    [Message](/api/message)

    All wechat messages will be encapsulated as a Message.

    -

    Examples/Ding-Dong-Bot

    +

    Examples/Ding-Dong-Bot

    diff --git a/src/api/contact.md b/src/api/contact.md index 2fde941..a972313 100644 --- a/src/api/contact.md +++ b/src/api/contact.md @@ -1,7 +1,7 @@ # Contact All wechat contacts(friend) will be encapsulated as a Contact. -[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/master/examples/contact-bot.ts) +[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/contact-bot.ts) **Kind**: global class @@ -46,11 +46,11 @@ const bot = new Wechaty() await bot.start() const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of your contact name in wechat -# 1. send text to contact +// 1. send text to contact await contact.say('welcome to wechaty!') -# 2. send media file to contact +// 2. send media file to contact import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') @@ -58,7 +58,7 @@ const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await contact.say(fileBox1) await contact.say(fileBox2) -# 3. send contact card to contact +// 3. send contact card to contact const contactCard = bot.Contact.load('contactId') await contact.say(contactCard) @@ -234,7 +234,7 @@ Get avatar picture file stream **Kind**: instance method of [Contact](/api/contact) **Example** ```js -# Save avatar to local file like `1-name.jpg` +// Save avatar to local file like `1-name.jpg` const file = await contact.avatar() const name = file.name diff --git a/src/api/friendship.md b/src/api/friendship.md index f168202..a1c67ea 100644 --- a/src/api/friendship.md +++ b/src/api/friendship.md @@ -5,7 +5,7 @@ Send, receive friend request, and friend confirmation events. 2. receive request(in friend event) 3. confirmation friendship(friend event) -[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/master/examples/friend-bot.ts) +[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/friend-bot.ts) **Kind**: global class @@ -37,13 +37,13 @@ bot.on('friendship', async friendship => { console.log(`received friend event.`) switch (friendship.type()) { - # 1. New Friend Request + // 1. New Friend Request case Friendship.Type.Receive: await friendship.accept() break - # 2. Friend Ship Confirmed + // 2. Friend Ship Confirmed case Friendship.Type.Confirm: console.log(`friend ship confirmed`) diff --git a/src/api/message.md b/src/api/message.md index dc957d4..53cd5f3 100644 --- a/src/api/message.md +++ b/src/api/message.md @@ -1,7 +1,7 @@ # Message All wechat messages will be encapsulated as a Message. -[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) **Kind**: global class @@ -133,7 +133,7 @@ bot Reply a Text or Media File message to the sender. **Kind**: instance method of [Message](/api/message) -**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) | Param | Type | Description | | --- | --- | --- | @@ -147,20 +147,20 @@ const bot = new Wechaty() bot .on('message', async m => { -# 1. send Image +// 1. send Image if (/^ding$/i.test(m.text())) { const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await msg.say(fileBox) } -# 2. send Text +// 2. send Text if (/^dong$/i.test(m.text())) { await msg.say('dingdingding') } -# 3. send Contact +// 3. send Contact if (/^lijiarui$/i.test(m.text())) { const contactCard = await bot.Contact.find({name: 'lijiarui'}) diff --git a/src/api/room.md b/src/api/room.md index 421aff1..33724ae 100644 --- a/src/api/room.md +++ b/src/api/room.md @@ -1,7 +1,7 @@ # Room All wechat rooms(groups) will be encapsulated as a Room. -[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/master/examples/room-bot.ts) +[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/room-bot.ts) **Kind**: global class @@ -52,22 +52,22 @@ await bot.start() // after logged in... const room = await bot.Room.find({topic: 'wechaty'}) -# 1. Send text inside Room +// 1. Send text inside Room await room.say('Hello world!') -# 2. Send media file inside Room +// 2. Send media file inside Room import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await room.say(fileBox1) await room.say(fileBox2) -# 3. Send Contact Card in a room +// 3. Send Contact Card in a room const contactCard = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say(contactCard) -# 4. Send text inside room and mention @mention contact +// 4. Send text inside room and mention @mention contact const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say('Hello world!', contact) ``` diff --git a/src/api/wechaty.md b/src/api/wechaty.md index 1976c0b..4e25591 100644 --- a/src/api/wechaty.md +++ b/src/api/wechaty.md @@ -27,7 +27,7 @@ See more: * [.logout()](#Wechatylogout) Promise.<void> * [.logonoff()](#Wechatylogonoff) boolean * ~~[.self()](#Wechatyself)~~ - * [.userSelf()](#WechatyuserSelf) [Contact](/api/contact) + * [.userSelf()](#WechatyuserSelf) ContactSelf * [.say(textOrContactOrFile)](#Wechatysay) Promise.<void> * [.version([forceNpm])](#Wechatyversion) string * _static_ @@ -81,7 +81,7 @@ see advanced [chaining usage](https://github.com/Chatie/wechaty-getting-started/ **Example** *(Event:scan)* ```js -# Scan Event will emit when the bot needs to show you a QR Code for scanning +// Scan Event will emit when the bot needs to show you a QR Code for scanning bot.on('scan', (url: string, code: number) => { console.log(`[${code}] Scan ${url} to login.` ) @@ -89,7 +89,7 @@ bot.on('scan', (url: string, code: number) => { ``` **Example** *(Event:login )* ```js -# Login Event will emit when bot login full successful. +// Login Event will emit when bot login full successful. bot.on('login', (user: ContactSelf) => { console.log(`user ${user} login`) @@ -97,7 +97,7 @@ bot.on('login', (user: ContactSelf) => { ``` **Example** *(Event:logout )* ```js -# Logout Event will emit when bot detected log out. +// Logout Event will emit when bot detected log out. bot.on('logout', (user: ContactSelf) => { console.log(`user ${user} logout`) @@ -105,7 +105,7 @@ bot.on('logout', (user: ContactSelf) => { ``` **Example** *(Event:message )* ```js -# Message Event will emit when there's a new message. +// Message Event will emit when there's a new message. wechaty.on('message', (message: Message) => { console.log(`message ${message} received`) @@ -113,7 +113,7 @@ wechaty.on('message', (message: Message) => { ``` **Example** *(Event:friendship )* ```js -# Friendship Event will emit when got a new friend request, or friendship is confirmed. +// Friendship Event will emit when got a new friend request, or friendship is confirmed. bot.on('friendship', (friendship: Friendship) => { if(friendship.type() === Friendship.Type.RECEIVE){ // 1. receive new friendship request from new contact @@ -131,7 +131,7 @@ bot.on('friendship', (friendship: Friendship) => { ``` **Example** *(Event:room-join )* ```js -# room-join Event will emit when someone join the room. +// room-join Event will emit when someone join the room. bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { const nameList = inviteeList.map(c => c.name()).join(',') @@ -140,7 +140,7 @@ bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { ``` **Example** *(Event:room-leave )* ```js -# room-leave Event will emit when someone leave the room. +// room-leave Event will emit when someone leave the room. bot.on('room-leave', (room: Room, leaverList: Contact[]) => { const nameList = leaverList.map(c => c.name()).join(',') @@ -149,7 +149,7 @@ bot.on('room-leave', (room: Room, leaverList: Contact[]) => { ``` **Example** *(Event:room-topic )* ```js -# room-topic Event will emit when someone change the room's topic. +// room-topic Event will emit when someone change the room's topic. bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Contact) => { console.log(`Room ${room.topic()} topic changed from ${oldTopic} to ${topic} by ${changer.name()}`) @@ -157,7 +157,7 @@ bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Cont ``` **Example** *(Event:error )* ```js -# error Event will emit when there's an error occurred. +// error Event will emit when there's an error occurred. bot.on('error', (error) => { console.error(error) @@ -245,7 +245,7 @@ Should use [userSelf](#WechatyuserSelf) instead ## wechaty.userSelf() -**Return the type of**: [Contact](/api/contact) +**Return the type of**: ContactSelf Get current user @@ -277,19 +277,19 @@ const bot = new Wechaty() await bot.start() // after logged in -# 1. send text to bot itself +// 1. send text to bot itself await bot.say('hello!') -# 2. send Contact to bot itself +// 2. send Contact to bot itself const contact = bot.Contact.load('contactId') await bot.say(contact) -# 3. send Image to bot itself from remote url +// 3. send Image to bot itself from remote url import { FileBox } from 'file-box' const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await bot.say(fileBox) -# 4. send Image to bot itself from local file +// 4. send Image to bot itself from local file import { FileBox } from 'file-box' const fileBox = FileBox.fromLocal('/tmp/text.jpg') await bot.say(fileBox) diff --git a/src/zh_api/README.md b/src/zh_api/README.md index 0ddac42..57b3c35 100644 --- a/src/zh_api/README.md +++ b/src/zh_api/README.md @@ -27,11 +27,11 @@ If you want to know how to get contact, see [Contact](/zh/api/contact)

    [Room](/zh/api/room)

    All wechat rooms(groups) will be encapsulated as a Room.

    -

    Examples/Room-Bot

    +

    Examples/Room-Bot

    [Contact](/zh/api/contact)

    All wechat contacts(friend) will be encapsulated as a Contact.

    -

    Examples/Contact-Bot

    +

    Examples/Contact-Bot

    [Friendship](/zh/api/friendship)

    Send, receive friend request, and friend confirmation events.

    @@ -40,11 +40,11 @@ If you want to know how to get contact, see [Contact](/zh/api/contact)

  • receive request(in friend event)
  • confirmation friendship(friend event)
  • -

    Examples/Friend-Bot

    +

    Examples/Friend-Bot

    [Message](/zh/api/message)

    All wechat messages will be encapsulated as a Message.

    -

    Examples/Ding-Dong-Bot

    +

    Examples/Ding-Dong-Bot

    diff --git a/src/zh_api/contact.md b/src/zh_api/contact.md index 18675ec..bf4c7a8 100644 --- a/src/zh_api/contact.md +++ b/src/zh_api/contact.md @@ -1,7 +1,7 @@ # Contact类 All wechat contacts(friend) will be encapsulated as a Contact. -[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/master/examples/contact-bot.ts) +[Examples/Contact-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/contact-bot.ts) **Kind**: global class @@ -46,11 +46,11 @@ const bot = new Wechaty() await bot.start() const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of your contact name in wechat -# 1. send text to contact +// 1. send text to contact await contact.say('welcome to wechaty!') -# 2. send media file to contact +// 2. send media file to contact import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') @@ -58,7 +58,7 @@ const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await contact.say(fileBox1) await contact.say(fileBox2) -# 3. send contact card to contact +// 3. send contact card to contact const contactCard = bot.Contact.load('contactId') await contact.say(contactCard) @@ -234,7 +234,7 @@ Get avatar picture file stream **Kind**: instance method of [Contact](/zh/api/contact) **Example** ```js -# Save avatar to local file like `1-name.jpg` +// Save avatar to local file like `1-name.jpg` const file = await contact.avatar() const name = file.name diff --git a/src/zh_api/friendship.md b/src/zh_api/friendship.md index 8062c1e..dac796a 100644 --- a/src/zh_api/friendship.md +++ b/src/zh_api/friendship.md @@ -5,7 +5,7 @@ Send, receive friend request, and friend confirmation events. 2. receive request(in friend event) 3. confirmation friendship(friend event) -[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/master/examples/friend-bot.ts) +[Examples/Friend-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/friend-bot.ts) **Kind**: global class @@ -37,13 +37,13 @@ bot.on('friendship', async friendship => { console.log(`received friend event.`) switch (friendship.type()) { - # 1. New Friend Request + // 1. New Friend Request case Friendship.Type.Receive: await friendship.accept() break - # 2. Friend Ship Confirmed + // 2. Friend Ship Confirmed case Friendship.Type.Confirm: console.log(`friend ship confirmed`) diff --git a/src/zh_api/message.md b/src/zh_api/message.md index 9176fef..24c6485 100644 --- a/src/zh_api/message.md +++ b/src/zh_api/message.md @@ -1,7 +1,7 @@ # Message类 All wechat messages will be encapsulated as a Message. -[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +[Examples/Ding-Dong-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) **Kind**: global class @@ -133,7 +133,7 @@ bot Reply a Text or Media File message to the sender. **Kind**: instance method of [Message](/zh/api/message) -**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/master/examples/ding-dong-bot.ts) +**See**: [Examples/ding-dong-bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) | Param | Type | Description | | --- | --- | --- | @@ -147,20 +147,20 @@ const bot = new Wechaty() bot .on('message', async m => { -# 1. send Image +// 1. send Image if (/^ding$/i.test(m.text())) { const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await msg.say(fileBox) } -# 2. send Text +// 2. send Text if (/^dong$/i.test(m.text())) { await msg.say('dingdingding') } -# 3. send Contact +// 3. send Contact if (/^lijiarui$/i.test(m.text())) { const contactCard = await bot.Contact.find({name: 'lijiarui'}) diff --git a/src/zh_api/room.md b/src/zh_api/room.md index e0eaa7a..9c774a1 100644 --- a/src/zh_api/room.md +++ b/src/zh_api/room.md @@ -1,7 +1,7 @@ # Room类 All wechat rooms(groups) will be encapsulated as a Room. -[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/master/examples/room-bot.ts) +[Examples/Room-Bot](https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/room-bot.ts) **Kind**: global class @@ -52,22 +52,22 @@ await bot.start() // after logged in... const room = await bot.Room.find({topic: 'wechaty'}) -# 1. Send text inside Room +// 1. Send text inside Room await room.say('Hello world!') -# 2. Send media file inside Room +// 2. Send media file inside Room import { FileBox } from 'file-box' const fileBox1 = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') const fileBox2 = FileBox.fromLocal('/tmp/text.txt') await room.say(fileBox1) await room.say(fileBox2) -# 3. Send Contact Card in a room +// 3. Send Contact Card in a room const contactCard = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say(contactCard) -# 4. Send text inside room and mention @mention contact +// 4. Send text inside room and mention @mention contact const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member await room.say('Hello world!', contact) ``` diff --git a/src/zh_api/wechaty.md b/src/zh_api/wechaty.md index e155b58..93aa8c2 100644 --- a/src/zh_api/wechaty.md +++ b/src/zh_api/wechaty.md @@ -27,7 +27,7 @@ See more: * [.logout()](#Wechatylogout) Promise.<void> * [.logonoff()](#Wechatylogonoff) boolean * ~~[.self()](#Wechatyself)~~ - * [.userSelf()](#WechatyuserSelf) [Contact](/zh/api/contact) + * [.userSelf()](#WechatyuserSelf) ContactSelf * [.say(textOrContactOrFile)](#Wechatysay) Promise.<void> * [.version([forceNpm])](#Wechatyversion) string * _static_ @@ -81,7 +81,7 @@ see advanced [chaining usage](https://github.com/Chatie/wechaty-getting-started/ **Example** *(Event:scan)* ```js -# Scan Event will emit when the bot needs to show you a QR Code for scanning +// Scan Event will emit when the bot needs to show you a QR Code for scanning bot.on('scan', (url: string, code: number) => { console.log(`[${code}] Scan ${url} to login.` ) @@ -89,7 +89,7 @@ bot.on('scan', (url: string, code: number) => { ``` **Example** *(Event:login )* ```js -# Login Event will emit when bot login full successful. +// Login Event will emit when bot login full successful. bot.on('login', (user: ContactSelf) => { console.log(`user ${user} login`) @@ -97,7 +97,7 @@ bot.on('login', (user: ContactSelf) => { ``` **Example** *(Event:logout )* ```js -# Logout Event will emit when bot detected log out. +// Logout Event will emit when bot detected log out. bot.on('logout', (user: ContactSelf) => { console.log(`user ${user} logout`) @@ -105,7 +105,7 @@ bot.on('logout', (user: ContactSelf) => { ``` **Example** *(Event:message )* ```js -# Message Event will emit when there's a new message. +// Message Event will emit when there's a new message. wechaty.on('message', (message: Message) => { console.log(`message ${message} received`) @@ -113,7 +113,7 @@ wechaty.on('message', (message: Message) => { ``` **Example** *(Event:friendship )* ```js -# Friendship Event will emit when got a new friend request, or friendship is confirmed. +// Friendship Event will emit when got a new friend request, or friendship is confirmed. bot.on('friendship', (friendship: Friendship) => { if(friendship.type() === Friendship.Type.RECEIVE){ // 1. receive new friendship request from new contact @@ -131,7 +131,7 @@ bot.on('friendship', (friendship: Friendship) => { ``` **Example** *(Event:room-join )* ```js -# room-join Event will emit when someone join the room. +// room-join Event will emit when someone join the room. bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { const nameList = inviteeList.map(c => c.name()).join(',') @@ -140,7 +140,7 @@ bot.on('room-join', (room: Room, inviteeList: Contact[], inviter: Contact) => { ``` **Example** *(Event:room-leave )* ```js -# room-leave Event will emit when someone leave the room. +// room-leave Event will emit when someone leave the room. bot.on('room-leave', (room: Room, leaverList: Contact[]) => { const nameList = leaverList.map(c => c.name()).join(',') @@ -149,7 +149,7 @@ bot.on('room-leave', (room: Room, leaverList: Contact[]) => { ``` **Example** *(Event:room-topic )* ```js -# room-topic Event will emit when someone change the room's topic. +// room-topic Event will emit when someone change the room's topic. bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Contact) => { console.log(`Room ${room.topic()} topic changed from ${oldTopic} to ${topic} by ${changer.name()}`) @@ -157,7 +157,7 @@ bot.on('room-topic', (room: Room, topic: string, oldTopic: string, changer: Cont ``` **Example** *(Event:error )* ```js -# error Event will emit when there's an error occurred. +// error Event will emit when there's an error occurred. bot.on('error', (error) => { console.error(error) @@ -245,7 +245,7 @@ Should use [userSelf](#WechatyuserSelf) instead ## wechaty.userSelf() -**Return the type of**: [Contact](/zh/api/contact) +**Return the type of**: ContactSelf Get current user @@ -277,19 +277,19 @@ const bot = new Wechaty() await bot.start() // after logged in -# 1. send text to bot itself +// 1. send text to bot itself await bot.say('hello!') -# 2. send Contact to bot itself +// 2. send Contact to bot itself const contact = bot.Contact.load('contactId') await bot.say(contact) -# 3. send Image to bot itself from remote url +// 3. send Image to bot itself from remote url import { FileBox } from 'file-box' const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png') await bot.say(fileBox) -# 4. send Image to bot itself from local file +// 4. send Image to bot itself from local file import { FileBox } from 'file-box' const fileBox = FileBox.fromLocal('/tmp/text.jpg') await bot.say(fileBox)