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 docs Chinese version #1530

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
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
20 changes: 10 additions & 10 deletions docusaurus/docs/api/contact-self.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ Bot itself will be encapsulated as a ContactSelf.

**Kind**: global class

* [ContactSelf](contact-self.md#contactself)
* [intance](contact-self.md#contactself)
* [contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>`](contact-self.md#contactselfavatarfile-⇒-promise)
* [contactSelf.qrcode\(\) ⇒ `Promise <string>`](contact-self.md#contactselfqrcode-⇒-promise)
* [contactSelf.signature\(signature\) ⇒ `Promise <string>`](contact-self.md#contactselfsignaturesignature)
* [contactSelf.name\(\[name\]\) ⇒ `Promise <void> | string`](contact-self.md#contactselfname-⇒-promisestring)
* [ContactSelf](/zh/docs/api/contact-self.md#contactself)
* [intance](/zh/docs/api/contact-self.md#contactself)
* [contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>`](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise)
* [contactSelf.qrcode\(\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise)
* [contactSelf.signature\(signature\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfsignaturesignature)
* [contactSelf.name\(\[name\]\) ⇒ `Promise <void> | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring)
Copy link
Contributor

Choose a reason for hiding this comment

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

The updates to the links for ContactSelf and its methods to include the full path /docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/ are a significant improvement for navigation within the documentation. This ensures that users are directed to the correct version of the documentation based on their language preference.

However, there's a typo in the word "instance" on line 16, which is currently spelled as "intance". Correcting this typo will improve the readability and professionalism of the documentation.

-  * [intance](/zh/docs/api/contact-self.md#contactself)
+  * [instance](/zh/docs/api/contact-self.md#contactself)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* [ContactSelf](/zh/docs/api/contact-self.md#contactself)
* [intance](/zh/docs/api/contact-self.md#contactself)
* [contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>`](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise)
* [contactSelf.qrcode\(\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise)
* [contactSelf.signature\(signature\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfsignaturesignature)
* [contactSelf.name\(\[name\]\) ⇒ `Promise <void> | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring)
* [ContactSelf](/zh/docs/api/contact-self.md#contactself)
* [instance](/zh/docs/api/contact-self.md#contactself)
* [contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>`](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise)
* [contactSelf.qrcode\(\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise)
* [contactSelf.signature\(signature\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfsignaturesignature)
* [contactSelf.name\(\[name\]\) ⇒ `Promise <void> | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring)


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

GET / SET bot avatar

**Kind**: instance method of [`ContactSelf`](contact-self.md#ContactSelf)
**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)

| Param | Type |
| :--- | :--- |
Expand Down Expand Up @@ -59,7 +59,7 @@ bot.on('login', user => {

Get bot qrcode

**Kind**: instance method of [`ContactSelf`](contact-self.md#ContactSelf)
**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)

#### Example

Expand All @@ -77,7 +77,7 @@ bot.on('login', async user => {

Change bot signature

**Kind**: instance method of [`ContactSelf`](contact-self.md#ContactSelf)
**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)

| Param | Description |
| :--- | :--- |
Expand All @@ -100,7 +100,7 @@ bot.on('login', async user => {

Get or change bot name.

**Kind**: instance method of [`ContactSelf`](contact-self.md#contactself)
**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#contactself)

| Param | Description |
| :--- | :--- |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: ContactSelf
---

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

## ContactSelf

> 备注:这个类继承自 Contact

**Kind**: global class

* [ContactSelf](/zh/docs/api/contact-self.md#contactself)
* [intance](/zh/docs/api/contact-self.md#contactself)
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a typo in the word "instance" (written as "intance"). Correcting this typo will improve the documentation's accuracy.

-  * [intance](/zh/docs/api/contact-self.md#contactself)
+  * [instance](/zh/docs/api/contact-self.md#contactself)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* [intance](/zh/docs/api/contact-self.md#contactself)
* [instance](/zh/docs/api/contact-self.md#contactself)

* [contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>`](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise)
* [contactSelf.qrcode\(\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise)
* [contactSelf.signature\(signature\) ⇒ `Promise <string>`](/zh/docs/api/contact-self.md#contactselfsignaturesignature)
* [contactSelf.name\(\[name\]\) ⇒ `Promise <void> | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring)

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

设置机器人的头像

**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#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`](/zh/docs/api/contact-self.md#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`](/zh/docs/api/contact-self.md#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`](/zh/docs/api/contact-self.md#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