-
Notifications
You must be signed in to change notification settings - Fork 346
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
Changes from 17 commits
0e19067
35657c5
da09d62
4f9ce94
a901f51
1d2322e
017a7d6
a4ae0bb
b7f04ec
a96b7d4
15a2b3e
92fc45b
54d6dbe
19d4df1
4390b64
7ad16aa
80ead80
49d91a1
17a45be
7262d23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||
* [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<FileBox>}\)_ | ||||||
|
||||||
```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) | ||||||
} | ||||||
}) | ||||||
``` |
There was a problem hiding this comment.
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.
Committable suggestion