Skip to content

Commit

Permalink
doc(readme): update doc to wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bcho committed Mar 11, 2017
1 parent 4e50022 commit b621601
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 270 deletions.
139 changes: 3 additions & 136 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![@BearyChat](http://openapi.beary.chat/badge.svg)](http://openapi.beary.chat/join)
[![Build Status](https://travis-ci.org/bearyinnovative/bearychat.js.svg)](https://travis-ci.org/bearyinnovative/bearychat.js)
![Development Status](https://img.shields.io/badge/status-WIP-yellow.svg?style=flat-square)
![Development Status](https://img.shields.io/badge/status-1.0.0-greeen.svg?style=flat-square)

[BearyChat]: https://bearychat.com

Expand All @@ -14,18 +14,9 @@

- [Install](#install)
- [Usage](#usage)
* [`incoming.send`](#incomingsend)
* [`incoming.builder`](#incomingbuilder)
* [`rtm.start`](#rtmstart)
* [`rtm.currentTeamInfo`](#rtmcurrentteaminfo)
* [`rtm.currentTeamMembers`](#rtmcurrentteammembers)
* [`rtm.currentTeamChannels`](#rtmcurrentteamchannels)
* [`rtm.userInfo`](#rtmuserinfo)
* [`rtm.channelInfo`](#rtmchannelinfo)
* [`rtm.message`](#rtmmessage)
* [`rtm.loop`](#rtmloop)
- [Test](#test)
- [Contributing](#contributing)
* [Generating API Client](#generating-api-client)
- [LICENSE](#license)

<!-- tocstop -->
Expand All @@ -44,131 +35,7 @@ $ yarn add bearychat

## Usage

### `incoming.send`

```javascript
import { incoming } from 'bearychat';

const myWebhookUri = 'https://hook.bearychat.com/incoming/keep-calm-and-pusing';

incoming
.send(myWebhookUri, { text: 'Hello, world' })
.then(() => {
console.log('incoming sent!');
});
```

### `incoming.builder`

```javascript
import { incoming } from 'bearychat';

incoming
.withText('Hello, world') // or .withMarkdown('**Hello, world**')
.to('扯犊子')
.withAttachment({ text: 'It is simple,' })
.withAttachment({ text: 'but colorful', color: '#ffa500' })
.build();
```

### `rtm.start`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.start(rtmToken)
.then((user) => {
console.log(user);
});
```

### `rtm.currentTeamInfo`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamInfo(rtmToken)
.then((team) => {
console.log(team);
});
```

### `rtm.currentTeamMembers`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamMembers(rtmToken)
.then((members) => {
console.log(members);
});
```

### `rtm.currentTeamChannels`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamChannels(rtmToken)
.then((channels) => {
console.log(channels);
});
```

### `rtm.userInfo`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';
const userId = '=bw4242';

rtm.userInfo(rtmToken, userId)
.then((user) => {
console.log(user);
});
```

### `rtm.channelInfo`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';
const channelId = '=bw4242';

rtm.channelInfo(rtmToken, channelId)
.then((channel) => {
console.log(channel);
});
```

### `rtm.message`

Provides handful helpers for rtm message parsing.

### `rtm.loop`

To achive more flexible usage, `bearychat.js` won't provide any implementations
for `rtm.loop`. You can use [`examples/rtm_loop`](./examples/rtm_loop) as
implementation reference.

Basically, `rtm.loop` contains 3 stages:

1. `rtm.start`: Use rtm token to authenticate user and open a websocket
connection.
2. `ping`: Keep sending `type=ping` message to server after connected. Pinging
interval with `5000ms` is suggested.
3. `loop`: Subscribe to websocket's message event and consume the message comes
from the server. You can use `rtm.message` for message parsing.
NB: WIP

## Test

Expand Down
136 changes: 2 additions & 134 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@

[![@BearyChat](http://openapi.beary.chat/badge.svg)](http://openapi.beary.chat/join)
[![Build Status](https://travis-ci.org/bearyinnovative/bearychat.js.svg)](https://travis-ci.org/bearyinnovative/bearychat.js)
![Development Status](https://img.shields.io/badge/status-WIP-yellow.svg?style=flat-square)
![Development Status](https://img.shields.io/badge/status-1.0.0-greeen.svg?style=flat-square)

[BearyChat]: https://bearychat.com

<!-- toc -->

- [安装](#%E5%AE%89%E8%A3%85)
- [用例](#%E7%94%A8%E4%BE%8B)
* [`incoming.send`](#incomingsend)
* [`incoming.builder`](#incomingbuilder)
* [`rtm.start`](#rtmstart)
* [`rtm.currentTeamInfo`](#rtmcurrentteaminfo)
* [`rtm.currentTeamMembers`](#rtmcurrentteammembers)
* [`rtm.currentTeamChannels`](#rtmcurrentteamchannels)
* [`rtm.userInfo`](#rtmuserinfo)
* [`rtm.channelInfo`](#rtmchannelinfo)
* [`rtm.message`](#rtmmessage)
* [`rtm.loop`](#rtmloop)
- [测试](#%E6%B5%8B%E8%AF%95)
- [贡献](#%E8%B4%A1%E7%8C%AE)
- [LICENSE](#license)
Expand All @@ -42,129 +32,7 @@ $ yarn add bearychat

## 用例

### `incoming.send`

```javascript
import { incoming } from 'bearychat';

const myWebhookUri = 'https://hook.bearychat.com/incoming/keep-calm-and-pusing';

incoming
.send(myWebhookUri, { text: 'Hello, world' })
.then(() => {
console.log('incoming sent!');
});
```

### `incoming.builder`

```javascript
import { incoming } from 'bearychat';

incoming
.withText('Hello, world') // or .withMarkdown('**Hello, world**')
.to('扯犊子')
.withAttachment({ text: 'It is simple,' })
.withAttachment({ text: 'but colorful', color: '#ffa500' })
.build();
```

### `rtm.start`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.start(rtmToken)
.then((user) => {
console.log(user);
});
```

### `rtm.currentTeamInfo`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamInfo(rtmToken)
.then((team) => {
console.log(team);
});
```

### `rtm.currentTeamMembers`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamMembers(rtmToken)
.then((members) => {
console.log(members);
});
```

### `rtm.currentTeamChannels`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';

rtm.currentTeamChannels(rtmToken)
.then((channels) => {
console.log(channels);
});
```

### `rtm.userInfo`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';
const userId = '=bw4242';

rtm.userInfo(rtmToken, userId)
.then((user) => {
console.log(user);
});
```

### `rtm.channelInfo`

```javascript
import { rtm } from 'bearychat';

const rtmToken = 'keep-secret-and-safe';
const channelId = '=bw4242';

rtm.channelInfo(rtmToken, channelId)
.then((channel) => {
console.log(channel);
});
```

### `rtm.message`

提供一系列解析 RTM 消息的函数。

### `rtm.loop`

为了提供更加灵活的功能,`bearychat.js` 不会提供 `rtm.loop` 的实现。你可以使用
[`examples/rtm_loop`](./examples/rtm_loop) 作为参考。

简单来说,`rtm.loop` 包含 3 个阶段:

1. `rtm.start`: 使用 RTM token 来进行认证,并获得 websocket 连接地址。
2. `ping`: 在连接上服务器之后,需要持续发送 `type=ping` 的消息来保持连接。
建议发送间隔为 `5000ms`
3. `loop`: 订阅 websocket 连接的消息事件。收到来自服务器的消息后可以
通过 `rtm.messsage` 来解析处理消息。
**整理中**

## 测试

Expand Down

0 comments on commit b621601

Please sign in to comment.