Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API documentation Chinese version #1531

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docusaurus/i18n/references/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
slug: /references/
title: Wechaty References Overview
sidebar_label: 'Overview'
---

import { Toc as ApiToc } from '../api/overview.mdx'
import { Toc as SpecToc } from '../specs/overview.mdx'

The reference guide contains the technical description of the machinery. They are code determined and information oriented. The references guides contain clear descriptions of Classes, API, Functions, Methods, Attributes, and many more technical aspects of the software. The Wechaty references aim to guide the end-users completely about Wechaty.

## References Index

1. [API References](../api/overview.mdx)
1. [Polyglot](../../../docs/polyglot/overview.mdx)
1. [Puppet Providers](../../../docs/puppet-providers/overview.mdx)
1. [Puppet Services](../../../docs/puppet-services/overview.mdx)
1. [Specifications](../../../docs/specs/overview.mdx)
Comment on lines +10 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The verification process has confirmed that the files referenced by the links in the docusaurus/i18n/references/overview.mdx document do not exist at the specified paths. This indicates that the review comment is valid, as it emphasizes the importance of ensuring that all links are working and lead to the correct documentation pages to avoid confusion for the readers.

Analysis chain

The overview of Wechaty references is well-structured, providing a clear index to various important aspects of Wechaty documentation. However, ensure that all the links are working and lead to the correct documentation pages to avoid confusion for the readers.


Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the accessibility of all links.
links=(
  "../api/overview.mdx"
  "../../../docs/polyglot/overview.mdx"
  "../../../docs/puppet-providers/overview.mdx"
  "../../../docs/puppet-services/overview.mdx"
  "../../../docs/specs/overview.mdx"
)
for link in "${links[@]}"; do
  # Assuming a function check_link exists that returns non-zero for broken links
  check_link "$link" || echo "Broken link: $link"
done

Length of output: 1498



Script:

#!/bin/bash
# Verify the existence of files referenced by the links.
base_path="docusaurus/i18n/references"

# Convert the relative paths to paths relative to the repository root
links=(
  "docusaurus/i18n/api/overview.mdx"
  "docs/polyglot/overview.mdx"
  "docs/puppet-providers/overview.mdx"
  "docs/puppet-services/overview.mdx"
  "docs/specs/overview.mdx"
)

# Check each link for existence
for link in "${links[@]}"; do
  if [ ! -f "$link" ]; then
    echo "Missing file: $link"
  fi
done

Length of output: 1080

Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: ContactSelf
---

机器人自己的信息将会封装一个ContactSelf 类。这个类继承自 Contact。

## ContactSelf

> 备注:这个类继承自 Contact

**Kind**: global class

* ContactSelf
* 实例
* contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>`
* contactSelf.qrcode\(\) ⇒ `Promise <string>`
* contactSelf.signature\(signature\) ⇒ `Promise <string>`
* contactSelf.name\(\[name\]\) ⇒ `Promise <void> | string`

### contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>`

设置机器人的头像

**Kind**: `ContactSelf`的实例方法

| Param | Type |
| :--- | :--- |
| \[file\] | `FileBox` |

**示例** _\( GET the avatar for bot, return {Promise&lt;FileBox&gt;}\)_

```javascript
bot.on('login', async user => {
console.log(`user ${user} login`)
const file = await user.avatar()
const name = file.name
await file.toFile(name, true)
console.log(`Save bot avatar: ${user.name()} with avatar file: ${name}`)
})

### contactSelf.qrcode\(\) ⇒ `Promise <string>`

获取机器人的二维码。

**Kind**: `ContactSelf`的实例方法

#### 示例

```javascript
import { generate } from 'qrcode-terminal'
bot.on('login', async user => {
console.log(`user ${user} login`)
const qrcode = await user.qrcode()
console.log(`Following is the bot qrcode!`)
generate(qrcode, { small: true })
})
```

### contactSelf.signature\(signature\) ⇒ `Promise <void>`

修改机器人签名。

**Kind**: `ContactSelf`的实例方法

| Param | Description |
| :--- | :--- |
| signature | 机器人要修改的签名内容 |

#### 示例

```javascript
bot.on('login', async user => {
console.log(`user ${user} login`)
try {
await user.signature(`Signature changed by wechaty on ${new Date()}`)
} catch (e) {
console.error('change signature failed', e)
}
})
```

### contactSelf.name\(\[name\]\) ⇒ `Promise<void> | string`

修改机器人昵称。

**Kind**: `ContactSelf`的实例方法

| Param | Description |
| :--- | :--- |
| \[name\] | 机器人要修改的昵称内容 |

#### 示例

```javascript
bot.on('login', async user => {
console.log(`user ${user} login`)
const oldName = user.name() // get bot name
try {
await user.name(`${oldName}-${new Date().getTime()}`) // change bot name
} catch (e) {
console.error('change name failed', e)
}
})
```
Loading
Loading