From 0e1906705a247fb336f61301f6a99c7f1295da08 Mon Sep 17 00:00:00 2001 From: comeonzhj Date: Fri, 8 Mar 2024 17:18:49 +0800 Subject: [PATCH 01/19] add API docs Chinese version --- .../current/api/contact-self.md | 117 ++++ .../current/api/contact.md | 307 +++++++++ .../current/api/friendship.md | 189 ++++++ .../current/api/message.md | 357 +++++++++++ .../current/api/overview.mdx | 25 + .../current/api/room-invitation.md | 74 +++ .../current/api/room.md | 589 ++++++++++++++++++ .../current/api/wechaty-class.md | 18 + .../current/api/wechaty.md | 389 ++++++++++-- 9 files changed, 2029 insertions(+), 36 deletions(-) create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/overview.mdx create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md create mode 100644 docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md new file mode 100644 index 00000000000..8f4402f79b1 --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md @@ -0,0 +1,117 @@ +--- +title: ContactSelf +--- + +机器人自己的信息将会封装一个ContactSelf 类。这个类继承自 Contact。 + +## ContactSelf + +> 备注:这个类继承自 Contact + +**Kind**: global class + +* [ContactSelf](contact-self.md#contactself) + * [intance](contact-self.md#contactself) + * [contactSelf.avatar\(\[file\]\) ⇒ `Promise `](contact-self.md#contactselfavatarfile-⇒-promise) + * [contactSelf.qrcode\(\) ⇒ `Promise `](contact-self.md#contactselfqrcode-⇒-promise) + * [contactSelf.signature\(signature\) ⇒ `Promise `](contact-self.md#contactselfsignaturesignature) + * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](contact-self.md#contactselfname-⇒-promisestring) + +### contactSelf.avatar\(\[file\]\) ⇒ `Promise ` + +设置机器人的头像 + +**Kind**: [`ContactSelf`](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}`) +}) +``` + +**示例** _\(SET the avatar for a bot\)_ + +```javascript +import { FileBox } from 'file-box' +bot.on('login', user => { + console.log(`user ${user} login`) + const fileBox = FileBox.fromUrl('https://wechaty.github.io/wechaty/images/bot-qr-code.png') + await user.avatar(fileBox) + console.log(`Change bot avatar successfully!`) +}) +``` + +### contactSelf.qrcode\(\) ⇒ `Promise ` + +获取机器人的二维码。 + +**Kind**: [`ContactSelf`](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 ` + +修改机器人签名。 + +**Kind**: [`ContactSelf`](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 | string` + +修改机器人昵称。 + +**Kind**: [`ContactSelf`](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) + } +}) +``` \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md new file mode 100644 index 00000000000..831b6ff7e39 --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -0,0 +1,307 @@ +--- +title: Contact Class +--- + +所有的联系人(好友)都会被封装成Contact类实例。 + +## Classes + +所有的联系人(好友)都会被封装成Contact类实例。 +[Examples/Contact-Bot](https://github.com/wechaty/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/contact-bot.ts) + +## Contact + +所有的联系人(好友)都会被封装成Contact类实例。 + +### Properties + +| 名称 | 类型 | 描述 | +| :--- | :--- | :--- | +| id | `string` | 获取联系人id,这个id 是否为永久唯一id 取决于您使用什么puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) | + +## Global Class `Contact` + +### 实例方法 + +| 实例方法 | 返回类型 | +|--------------------------------------|-----------------------------------------------------------------------| +| say(text 或 Contact 或 File 或 Url) | `Promise` | +| name() | `String` | +| alias(newAlias) | `Promise` | +| friend() | `Boolean 或 null` | +| type() | `ContactType.Unknown 或 ContactType.Personal 或 ContactType.Official` | +| gender() | `ContactGender.Unknown 或 ContactGender.Male 或 ContactGender.Female` | +| province() | `String 或 null` | +| city() | `String 或 null` | +| avatar() | `Promise` | +| sync() | `Promise` | +| self() | `Boolean` | + +### 静态方法 + +| 静态方法 | 返回类型 | +|---------------------------|-----------------------------| +| find(query) | `Promise ` | +| findAll(Query Arguements) | `Promise ` | + +### contact.say\(textOrContactOrFileOrUrlLinkOrMiniProgram\) ⇒ `Promise ` + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +| Param | Type | Description | +| :--- | :--- | :--- | +| text或Contact或File或UrlLink或MiniProgram | `string` \| [`Contact`](contact.md#Contact) \| `FileBox` \| `UrlLink` \| `MiniProgram` | 给微信好友发送文本,联系人名片,文件或者链接。你可以使用[FileBox](https://www.npmjs.com/package/file-box) 来发送文件。| + +### 示例 + +```javascript +import { FileBox } from 'file-box' +import { + Wechaty, + UrlLink, + MiniProgram, +} from 'wechaty' + +const bot = new Wechaty() +await bot.start() +const contact = await bot.Contact.find({name: 'lijiarui'}) + +// 1. 为contact发短信 + +await contact.say('welcome to wechaty!') + +// 2. 为contact发文件 + +import { FileBox } from 'file-box' +const fileBox1 = FileBox.fromUrl('https://wechaty.github.io/wechaty/images/bot-qr-code.png') +const fileBox2 = FileBox.fromFile('/tmp/text.txt') +await contact.say(fileBox1) +await contact.say(fileBox2) + +// 3. 为contact发contact card + +const contactCard = bot.Contact.load('contactId') +await contact.say(contactCard) + +// 4. 为contact发url链接 + +const urlLink = new UrlLink({ + description : 'WeChat Bot SDK for Individual Account, Powered by TypeScript, Docker, and Love', + thumbnailUrl: 'https://avatars0.githubusercontent.com/u/25162437?s=200&v=4', + title : 'Welcome to Wechaty', + url : 'https://github.com/wechaty/wechaty', +}) +await contact.say(urlLink) + +// 5. 发小程序 (仅`wechaty-puppet-macpro`支持) + +const miniProgram = new MiniProgram ({ + appid : 'gh_0aa444a25adc', + title : '我正在使用Authing认证身份,你也来试试吧', + pagePath : 'routes/explore.html', + description : '身份管家', + thumbUrl : '30590201000452305002010002041092541302033d0af802040b30feb602045df0c2c5042b777875706c6f61645f31373533353339353230344063686174726f6f6d3131355f313537363035393538390204010400030201000400', + thumbKey : '42f8609e62817ae45cf7d8fefb532e83', +}); + +await contact.say(miniProgram); +``` + +### contact.name\(\) ⇒ `string` + +获取联系人的昵称。 + +### 示例 + +```javascript +const name = contact.name() +``` + +### contact.alias\(newAlias\) ⇒ `Promise ` + +获取/设置/删除 好友的备注。如果设置备注过于频繁,设置将会失效\(比如1分钟设置60次\)。 + +| Param | Type | +| :--- | :--- | +| newAlias | `none` \| `string` \| `null` | + +### 示例 \( GET contact的备注, return {\(Promise<string \| null>\)}\) + +```javascript +const alias = await 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) +} +``` + +### 示例 \(SET contact的备注\) + +```javascript +try { + await contact.alias('lijiarui') + console.log(`change ${contact.name()}'s alias successfully!`) +} catch (e) { + console.log(`failed to change ${contact.name()} alias!`) +} +``` + +### 示例 \(DELETE contact的备注\) + +```javascript +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!`) +} +``` + +### Contact.friend\(\) ⇒ `boolean` \| `null` + +判断这个联系人是否为机器人的好友。Returns: `boolean` 或 `null`, 是friend, return`true`,不是friend, return`false`,`null`是unknown + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +### 示例 + +```javascript +const isFriend = contact.friend() +``` + +### Contact.type\(\) ⇒ `ContactType.Unknown` \| `ContactType.Personal` \| `ContactType.Official` + +获取好友的类型,是公众号还是普通还有。 + +> 备注:ContactType 在这里是enum + +### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +const isOfficial = contact.type() === bot.Contact.Type.Official +``` + +### contact.gender\(\) ⇒ `ContactGender.Unknown` \| `ContactGender.Male` \| `ContactGender.Female` + +获取联系人的性别。 +> 备注:ContactGender在这里是enum + +### 示例 + +```javascript +const gender = contact.gender() === bot.Contact.Gender.Male +``` + +### Contact.province\(\) ⇒ `string` \| `null` + +获取联系人设置的省份信息。 + +### 示例 + +```javascript +const province = contact.province() +``` + +### Contact.city\(\) ⇒ `string` \| `null` + +获取联系人设置的城市信息。 + +### 示例 + +```javascript +const city = contact.city() +``` + +### Contact.avatar\(\) ⇒ `Promise ` + +获取联系人的头像。 + +### 示例 + +```javascript +// 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}`) +``` + +### Contact.sync\(\) ⇒ `Promise ` + +强制重新加载好友数据,会从低级别的 API 中重新同步一遍。 + +### 示例 + +```javascript +await contact.sync() +``` + +### Contact.self\(\) ⇒ `boolean` + +检测好友是否是机器人自己。 + +### 示例 + +```javascript +const isSelf = contact.self() +``` + +## Static Methods + +### Contact.find\(query\) ⇒ `Promise ` + +通过类似这样的命令查找联系人: {name: string \| RegExp} / {alias: string \| RegExp}。支持通过昵称或者备注查找。如果查到不止一个联系人,返回找到的第一个。能找contact, return `Promise`, 没有contact, return `null`. + +| Param | Type | +| :--- | :--- | +| query | [`ContactQueryFilter`](contact.md#ContactQueryFilter) | + +#### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +const contactFindByName = await bot.Contact.find({ name:"ruirui"} ) +const contactFindByAlias = await bot.Contact.find({ alias:"lijiarui"} ) +``` + +### Contact.findAll\(\[queryArg\]\) ⇒ `Promise ` + +通过`name`(昵称)或者`alias`(备注)查找联系人。用 Contact.findAll() 获取机器人的所有联系人列表。 + +#### 定义 + +* `name` 用户自己设置的昵称叫做name +* `alias` 机器人给这个用户设置的昵称叫做alias + +| Param | Type | +| :--- | :--- | +| queryArg | [`ContactQueryFilter`](contact.md#ContactQueryFilter) | + +#### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +const contactList = await bot.Contact.findAll() // get the contact list of the bot +const contactList = await bot.Contact.findAll({ name: 'ruirui' }) // find all of the contacts whose name is 'ruirui' +const contactList = await bot.Contact.findAll({ alias: 'lijiarui' }) // find all of the contacts whose alias is 'lijiarui' +``` + +## Typedefs + +### ContactQueryFilter + +搜索联系人的方式。 + +### Properties + +| Name | Type | Description | +| :--- | :--- | :--- | +| name | `string` | 用户自己设置的昵称叫做name | +| alias | `string` | 机器人或者其他人给这个用户设置的昵称叫做alias [更多](https://github.com/wechaty/wechaty/issues/365) | \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md new file mode 100644 index 00000000000..f11bbb9a2df --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md @@ -0,0 +1,189 @@ +--- +title: Friendship +--- + +Wechaty机器人允许你通过其名为`Friendship`的全球类结交朋友。本节完全是关于`Friendship`类的。 + +[Examples or Friend-Bot](https://github.com/wechaty/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/friend-bot.ts) + +## Global class Friendship + +发送,接受好友请求的Class,有以下三种: + +1. 发送好友请求 +2. 在 \(friend event\) 中收到好友请求 +3. 在 \(friend event\) 中确认好友请求 + +### 实例方法 + +| 实例方法 | 返回类型 | +|------------------|------------------| +| accept() | `Promise (void)` | +| hello() | `string` | +| contact() | `contact` | +| type() | `Friendshiptype` | + +### 静态方法 + +| 静态方法 | 返回类型 | +|----------------|------------------| +| add() | `Promise (void)` | + +### friendship.accept\(\) ⇒ `Promise ` + +通过好友请求。 + +#### 示例 + +```javascript +const bot = new Wechaty() +bot.on('friendship', async friendship => { + try { + console.log(`received friend event.`) + switch (friendship.type()) { + + // 1. 新好友请求 + + case bot.Friendship.Type.Receive: + await friendship.accept() + break + + // 2. 好友请求接受 + + case bot.Friendship.Type.Confirm: + console.log(`friend ship confirmed`) + break + } + } catch (e) { + console.error(e) + } +}) +.start() +``` + +### friendship.hello\(\) ⇒ `string` + +获取对方发送好友请求的验证信息。 + +**示例 ** _\(如内容是 \`ding\`, 接受好友请求\)_ + +```javascript +const bot = new Wechaty() +bot.on('friendship', async friendship => { + try { + console.log(`received friend event from ${friendship.contact().name()}`) + if (friendship.type() === bot.Friendship.Type.Receive && friendship.hello() === 'ding') { + await friendship.accept() + } + } catch (e) { + console.error(e) + } +} +.start() +``` + +### friendship.contact\(\) ⇒ `Contact` + +获取发送好友请求的联系人。 + +#### 示例 + +```javascript +const bot = new Wechaty() +bot.on('friendship', friendship => { + const contact = friendship.contact() + const name = contact.name() + console.log(`received friend event from ${name}`) +} +.start() +``` + +### friendship.type\(\) ⇒ `FriendshipType` + +返回好友请求的类型。 + +> 备注:在这里是enum: +> +> * FriendshipType.Unknown +> * FriendshipType.Confirm +> * FriendshipType.Receive +> * FriendshipType.Verify + +### 示例 _\(如内容是 \`ding\`, 接受好友请求\)_ + +```javascript +const bot = new Wechaty() +bot.on('friendship', async friendship => { + try { + if (friendship.type() === bot.Friendship.Type.Receive && friendship.hello() === 'ding') { + await friendship.accept() + } + } catch (e) { + console.error(e) + } +} +.start() +``` + +### Friendship.search\(phone\) ⇒ `Promise ` + +该方法通过电话号码搜索联系人并获取联系人。 +> 最佳实践:每分钟加1次,如果发送的过于频繁,你可能会被封号,每天能添加的好友数量是有上限的。 + +| Param | Type | Description | +| :--- | :--- | :--- | +| phone | `number` | 搜索电话号码 | + +#### 示例 + +```javascript +const phone = '131xxx1234' +const searchContact = await bot.Friendship.search({ + phone, +}) +``` + +### Friendship.add\(contact, options\) ⇒ `Promise ` + +发送好友请求给contact 发送的内容是 hello. +> 最佳实践:每分钟加1次,如果发送的过于频繁,你可能会被封号,每天能添加的好友数量是有上限的。 + +| Param | Type | Description | +| :--- | :--- | :--- | +| contact | `Contact` | 需要发送好友请求的联系人 | +| options | `FriendshipAddOptions` | 发送好友请求的内容 | + +#### 示例 \(Add搜索的contact\) + +```javascript +await bot.Friendship.add(searchContact, { hello: 'Nice to meet you! I am wechaty bot!' }) +``` + +#### 示例 \(add room member\) + +```javascript +const memberList = await room.memberList() +for (let i = 0; i < memberList.length; i++) { + await bot.Friendship.add(member, { + room: message.room(), + hello: 'Nice to meet you! I am wechaty bot!', + }) +} + +``` + +#### 示例 \(add contact card\) + +```javascript +if (message.type() === bot.Message.Type.Contact) { + const contact = await message.toContact() + const options = { + contact: message.talker(), + hello: 'Nice to meet you! I am wechaty bot!', + } + if (message.room()) { + options.room = message.room() + } + await bot.Friendship.add(contact, options) +} +``` \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md new file mode 100644 index 00000000000..6958b15fee4 --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md @@ -0,0 +1,357 @@ +--- +title: Message +--- +本节对消息类、其方法及其用途进行了清晰的描述。所有的微信消息会被封装成一个`Message`类。 + +[Examples/Ding-Dong-Bot](https://github.com/wechaty/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) + +## Global Class `Message` + +### 实例方法 + +| 实例方法 | 返回类型 | +|--------------------------------|---------------------| +| from\(\) | `Contact` 或 `null` | +| to\(\) | `Contact` 或 `null` | +| room\(\) | `Room` 或 `null` | +| text\(\) | `string` | +| say\(text Or Contact Or File\) | `Promise` | +| type\(\) | `MessageType` | +| self\(\) | `boolean` | +| mention\(\) | `Promise` | +| mentionSelf\(\) | `Promise` | +| forward\(to\) | `Promise` | +| date\(\) | `Date` | +| age\(\) | `Number` | +| toFileBox\(\) | `Promise` | +| toContact\(\) | `Promise` | +| toUrlLink\(\) | `Promise` | + +### 静态方法 + +| 静态方法 | 返回类型 | +|----------------|-------------| +| find\(\) | `Promise` | +| findAll\(\) | `Promise` | + +## 实例方法 + +### message.from\(\) ⇒ `Contact | null` + +获取发送消息的联系人。 +找不到发送的人,return `null`. + +### 示例 + +```javascript +const bot = new Wechaty() +bot +.on('message', async message => { + const contact = message.from() + const text = message.text() + const room = message.room() + if (room) { + const topic = await room.topic() + console.log(`Room: ${topic} Contact: ${contact.name()} Text: ${text}`) + } else { + console.log(`Contact: ${contact.name()} Text: ${text}`) + } +}) +.start() +``` + +### message.to\(\) ⇒ `Contact` \| `null` + +获取消息发送的联系人。在room中, return `null`。 使用Message.room\(\) 获取room信息。 + +### 示例 + +```javascript +const bot = new Wechaty() +bot +.on('message', async message => { + const contact = message.from() + const text = message.text() + const toContact = message.to() + if (toContact) { + const name = toContact.name() + console.log(`toContact: ${name} Contact: ${contact.name()} Text: ${text}`) + } else { + console.log(`Contact: ${contact.name()} Text: ${text}`) + } +}) +.start() +``` + +### message.room\(\) ⇒ `Room` \| `null` + +获取消息所在的room,如果这条消息不在room中,会返回`null`。 + +### 示例 + +```javascript +const bot = new Wechaty() +bot +.on('message', async message => { + const contact = message.from() + const text = message.text() + const room = message.room() + if (room) { + const topic = await room.topic() + console.log(`Room: ${topic} Contact: ${contact.name()} Text: ${text}`) + } else { + console.log(`Contact: ${contact.name()} Text: ${text}`) + } +}) +.start() +``` + +### message.text\(\) ⇒ `string` + +获取消息的文本内容。 + +### 示例 + +```javascript +const bot = new Wechaty() +bot +.on('message', async message => { + const contact = message.from() + const text = message.text() + const room = message.room() + if (room) { + const topic = await room.topic() + console.log(`Room: ${topic} Contact: ${contact.name()} Text: ${text}`) + } else { + console.log(`Contact: ${contact.name()} Text: ${text}`) + } +}) +.start() +``` + +### message.toRecalled\(\) ⇒ `Promise ` + +获取撤回消息的文本内容。 + +### 示例 + +```javascript +const bot = new Wechaty() +bot +.on('message', async message => { + if (message.type() === bot.Message.Type.Recalled) { + const recalledMessage = await message.toRecalled() + console.log(`Message: ${recalledMessage} has been recalled.`) + } +}) +.start() +``` + +### message.say\(text或Contact或File或UrlLink或MiniProgram\) ⇒ `Promise ` + +回复多媒体、微信名片、文本或者链接给这条消息的发送者。 + + +| Param | Type | Description | +| :--- | :--- | :--- | +| text 或 Contact 或 File 或 UrlLink 或 MiniProgram | `string` \| `Contact` \| `FileBox` \| `UrlLink` \| `MiniProgram` | 发送文本、名片或者文件 可以使用 [FileBox](https://www.npmjs.com/package/file-box) 来发送文件 | + +备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +**See🏻**: [Examples/ding-dong-bot](https://github.com/wechaty/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts) + +### 示例 + +```javascript +import { FileBox } from 'file-box' +import { + Wechaty, + UrlLink, + MiniProgram, +} from 'wechaty' + +const bot = new Wechaty() +bot +.on('message', async message => { + +// 1. 发照片 + + if (/^ding$/i.test(message.text())) { + const fileBox = FileBox.fromUrl('https://wechaty.github.io/wechaty/images/bot-qr-code.png') + await message.say(fileBox) + } + +// 2. 发短信 + + if (/^dong$/i.test(message.text())) { + await message.say('dingdingding') + } + +// 3. 发contact + + if (/^lijiarui$/i.test(message.text())) { + const contactCard = await bot.Contact.find({name: 'lijiarui'}) + if (!contactCard) { + console.log('not found') + return + } + await message.say(contactCard) + } + +// 4. 发链接 + + if (/^link$/i.test(message.text())) { + const urlLink = new UrlLink({ + description: 'Wechaty is a Bot SDK for Wechat Individual Account which can help you create a bot in 6 lines of javascript, with cross-platform support including Linux, Windows, Darwin(OSX/Mac) and Docker.', + thumbnailUrl: 'https://camo.githubusercontent.com/f310a2097d4aa79d6db2962fa42bb3bb2f6d43df/68747470733a2f2f6368617469652e696f2f776563686174792f696d616765732f776563686174792d6c6f676f2d656e2e706e67', + title: 'Wechaty', + url: 'https://github.com/wechaty/wechaty', + }); + + await message.say(urlLink); + } + +// 5. 发小程序 (仅 `wechaty-puppet-macpro`支持) + + if (/^mini-program$/i.test(message.text())) { + const miniProgram = new MiniProgram ({ + appid : 'gh_0aa444a25adc', + title : '我正在使用Authing认证身份,你也来试试吧', + pagePath : 'routes/explore.html', + thumbUrl : '30590201000452305002010002041092541302033d0af802040b30feb602045df0c2c5042b777875706c6f61645f31373533353339353230344063686174726f6f6d3131355f313537363035393538390204010400030201000400', + thumbKey : '42f8609e62817ae45cf7d8fefb532e83', + }); + + await message.say(miniProgram); + } +}) +.start() +``` + +### message.type\(\) ⇒ `MessageType` + +此方法获取Wechaty消息的类型。下面列出了支持的不同方法类型: + +| 消息类型 | +|------------------------| +| MessageType.Unknown | +| MessageType.Attachment | +| MessageType.Audio | +| MessageType.Contact | +| MessageType.Emoticon | +| MessageType.Image | +| MessageType.Text | +| MessageType.Video | +| MessageType.Url | + +### 示例 + +```javascript +const bot = new Wechaty() +if (message.type() === bot.Message.Type.Text) { + console.log('This is a text message') +} +``` + +### message.self\(\) ⇒ `boolean` + +查看这条消息是否为机器人发送的。 +message是自己发的,return `true`,是其他发的,return`false` + +### 示例 + +```javascript +if (message.self()) { + console.log('this message is sent by myself!') +} +``` + +### message.mention\(\) ⇒ `Promise ` + +获取在群中@的用户列表。 + +| | Web | Mac PC Client | iOS Mobile | android Mobile | +| :--- | :---: | :---: | :---: | :---: | +| \[You were mentioned\] tip \(\[有人@我\]的提示\) | ✘ | √ | √ | √ | +| Identify magic code \(8197\) by copy & paste in mobile | ✘ | √ | √ | ✘ | +| Identify magic code \(8197\) by programming | ✘ | ✘ | ✘ | ✘ | +| Identify two contacts with the same roomAlias by \[You were mentioned\] tip | ✘ | ✘ | √ | √ | + +### 示例 + +```javascript +const contactList = await message.mention() +console.log(contactList) +``` + +### message.mentionSelf\(\) ⇒ `Promise ` + +获取机器人是否在群里被@ 了。 +是被@了,return`true` + +### 示例 + +```javascript +if (await message.mentionSelf()) { + console.log('this message were mentioned me! [You were mentioned] tip ([有人@我]的提示)') +} +``` + +### message.forward\(to\) ⇒ `Promise ` + +转发收到的消息。 + +| Param | Type | Description | +| :--- | :--- | :--- | +| to (Recipient) | `Sayable` \| `Array` |Room 或者 Contact。指的是收消息方。 | + +### 示例 + +```javascript +const bot = new Wechaty() +bot +.on('message', async message => { + const room = await bot.Room.find({topic: 'wechaty'}) + if (room) { + await message.forward(room) + console.log('forward this message to wechaty room!') + } +}) +.start() +``` + +### message.date\(\) ⇒ `Date` + +消息发送的时间。 + +### message.age\(\) ⇒ `number` + +消息的时差。 +例如: 消息在`8:43:01`发送的,当我们在wechaty 上收到消息的时候,时间是`8:43:15`,那么 age\(\) 为 `8:43:15 - 8:43:01 = 14 (seconds)`。 + +### message.toFileBox\(\) ⇒ `Promise ` + +从消息中提取多媒体文件并把它 存入到FileBox 里面。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +### message.toContact\(\) ⇒ `Promise ` + +提取转发的微信好友名片内容,并封装成Contact 类型。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +### message.toUrlLink\(\) ⇒ `Promise ` + +该方法从消息中提取Url链接,并将其封装到UrlLink类中。 +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +## 静态方法 + +### Message.find\(\) ⇒ `Promise ` + +在缓存中找消息。 + +### Message.findAll\(\) ⇒ `Promise ` + +在缓存中找消息。 \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/overview.mdx b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/overview.mdx new file mode 100644 index 00000000000..e6014d9a0fe --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/overview.mdx @@ -0,0 +1,25 @@ +--- +slug: /api/ +title: Wechaty API +sidebar_label: 'API:简介' +--- + +import TOCInline from '@theme/TOCInline' +export const Toc = () => + + + + +## Wechaty API + +API—应用程序编程接口是为其他软件服务提供服务的软件接口。Wechaty API是一个非常易于导入的API,允许用户尽可能使用Wechaty的所有功能。本文档概述Wechaty API。 + +## 上手 + +以下是一个最简单上手的示例代码: + +## ES6/TypeScript + +```js +import { WechatyBuilder } from 'wechaty' +``` \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md new file mode 100644 index 00000000000..67c93fd8d22 --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md @@ -0,0 +1,74 @@ +--- +title: Room Invitation +--- + +## Room Invitation + +自动通过入群邀请。 + +| 实例方法 | 返回类型 | +|----------------|---------------| +| accept\(\) | `Promise` | +| inviter\(\) | `Promise`(Contact) | +| topic\(\) | `Promise` (String) | +| date\(\) | `Promise` (Date) | +| age\(\) | `Promise` (Number) | + +### roomInvitation.accept\(\) ⇒ `Promise ` + +自动通过入群邀请。 + +#### 示例 + +```javascript +const bot = new Wechaty() +bot.on('room-invite', async roomInvitation => { + try { + console.log(`received room-invite event.`) + await roomInvitation.accept() + } catch (e) { + console.error(e) + } +}) +.start() +``` + +### roomInvitation.inviter\(\) ⇒ `Promise ` + +获取发送入群邀请的联系人。 + +#### 示例 + +```javascript +const bot = new Wechaty() +bot.on('room-invite', async roomInvitation => { + const inviter = await roomInvitation.inviter() + const name = inviter.name() + console.log(`received room invitation event from ${name}`) +}) +.start() +``` + +### roomInvitation.topic\(\) ⇒ `Promise ` + +获取需要进的群的群名称。 + +#### 示例 + +```javascript +const bot = new Wechaty() +bot.on('room-invite', async roomInvitation => { + const topic = await roomInvitation.topic() + console.log(`received room invitation event from room ${topic}`) +}) +.start() +``` + +### roomInvitation.date\(\) ⇒ `Promise ` + +获取发送入群邀请的时间。 + +### roomInvitation.age\(\) ⇒ `Promise ` + +获取入群邀请的时间间隔。 +例如:入群邀请的发送时间在`8:43:15`, 当我们在Wechaty 上收到这个信息的时间是`8:43:01`, 那么age\(\)的值为: `8:43:15 - 8:43:01 = 14 (seconds)` \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md new file mode 100644 index 00000000000..593707b652e --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md @@ -0,0 +1,589 @@ +--- +title: Room +--- + +## Class + +### Room + +所有的微信群都会被封装成 Room 类。 + +[Examples/Room-Bot](https://github.com/wechaty/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/room-bot.ts) + +#### Properties + +| 名称 | 类型 | 描述 | +| :--- | :--- | :--- | +| id | `string` | 获取群id。这个id 是否是永久不变的id 取决于使用哪一个puppet,具体 查看puppet兼容性清单,参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) | + +## Global class `Room` + +### 实例方法 + +| 实例方法 | 返回类型 | +|-----------------------------------------------------|-------------------| +| sync() | `Promise` | +| say(text 或 Contact 或 File 或 Url, ...mentionList) | `Promise` | +| on(event, listener) | `Room` | +| add(contact) | `Promise` | +| del(contact) | `Promise` | +| quit() | `Promise` | +| topic(newTopic) | `Promise` | +| announce(text) | `Promise` | +| qrcode() | `Promise` | +| alias(contact) | `Promise` | +| has(contact) | `Promise` | +| memberAll(query) | `Promise` | +| member(queryArg) | `Promise` | +| owner() | `Contact 或 null` | +| avatar() | `Promise` | + +### 静态方法 + +| 静态方法 | 返回类型 | +|---------------------------|--------------------------| +| create(contactList,topic) | `Promise ` | +| findAll(query) | `Promise` | +| find(query) | `Promise 或 null` | + +### room.sync\(\) ⇒ `Promise ` + +强制加载群的数据,从底层API 重新加载数据。 + +#### 示例 + +```javascript +await room.sync() +``` + +### room.say\(text 或 Contact 或 File 或 UrlLink 或 MiniProgram, ...mentionList\) ⇒ `Promise ` + +在群内发消息,如果设置了 ...mentionList 参数,机器人在群内发送消息的时候还会@这些联系人。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +| Param | Type | Description | +| :--- | :--- | :--- | +| text 或 Contact 或 File 或 UrlLink 或 MiniProgram | `string` \| `Contact` \| `FileBox` \| `UrlLink` \| `MiniProgram` | 群内发送text或者media file或者链接。可以通过 [FileBox](https://www.npmjs.com/package/file-box) 来发送文件。 | +| ...mentionList | `Contact []` | 可选参数,当设置这个参数的时候,在群内发送文本消息会@这些联系人。 | + +#### 示例 + +```javascript +import { FileBox } from 'file-box' +import { + Wechaty, + UrlLink, + MiniProgram, +} from 'wechaty' + +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'wechaty'}) + +// 1. 在Room发短信 + +await room.say('Hello world!') + +// 2. 在Room发文件 + +import { FileBox } from 'file-box' +const fileBox1 = FileBox.fromUrl('https://wechaty.github.io/wechaty/images/bot-qr-code.png') +const fileBox2 = FileBox.fromLocal('/tmp/text.txt') +await room.say(fileBox1) +await room.say(fileBox2) + +// 3. 在room发contact card + +const contactCard = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of the room member +await room.say(contactCard) + +// 4. 在room发短信和@mention contact + +const members = await room.memberAll() // all members in this room +const someMembers = members.slice(0, 3); +await room.say('Hello world!', ...someMembers) + +// 5. 在room发链接 + +const linkPayload = new UrlLink({ + description : 'WeChat Bot SDK for Individual Account, Powered by TypeScript, Docker, and Love', + thumbnailUrl: 'https://avatars0.githubusercontent.com/u/25162437?s=200&v=4', + title : 'Welcome to Wechaty', + url : 'https://github.com/wechaty/wechaty', +}) +await room.say(linkPayload) + +// 6. 发小程序 (仅 `wechaty-puppet-macpro`支持) + +const miniProgram = new MiniProgram ({ + appid : 'gh_0aa444a25adc', + title : '我正在使用Authing认证身份,你也来试试吧', + pagePath : 'routes/explore.html', + description : '身份管家', + thumbUrl : '30590201000452305002010002041092541302033d0af802040b30feb602045df0c2c5042b777875706c6f61645f31373533353339353230344063686174726f6f6d3131355f313537363035393538390204010400030201000400', + thumbKey : '42f8609e62817ae45cf7d8fefb532e83', +}); +await room.say(miniProgram); +``` + +### room.on\(event, listener\) ⇒ `this` + +Return `this` - - Room for chain. + +| Param | Type | Description | +| :--- | :--- | :--- | +| event | [`RoomEventName`](room.md#RoomEventName) | 群内事件触发 | +| listener | [`RoomEventFunction`](room.md#RoomEventFunction) | 取决于是哪一个事件 | + +#### 示例 \(Event:join \) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'topic of your room'}) // change `event-room` to any room topic in your wechat +if (room) { + room.on('join', (room, inviteeList, inviter) => { + const nameList = inviteeList.map(c => c.name()).join(',') + console.log(`Room got new member ${nameList}, invited by ${inviter}`) + }) +} +``` + +#### 示例 \(Event:leave \) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'topic of your room'}) // change `event-room` to any room topic in your wechat +if (room) { + room.on('leave', (room, leaverList) => { + const nameList = leaverList.map(c => c.name()).join(',') + console.log(`Room lost member ${nameList}`) + }) +} +``` + +#### 示例 \(Event:topic \) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'topic of your room'}) // change `event-room` to any room topic in your wechat +if (room) { + room.on('topic', (room, topic, oldTopic, changer) => { + console.log(`Room topic changed from ${oldTopic} to ${topic} by ${changer.name()}`) + }) +} +``` + +#### 示例 \(Event:invite \) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'topic of your room'}) // change `event-room` to any room topic in your wechat +if (room) { + room.on('invite', roomInvitation => roomInvitation.accept()) +} +``` + +### room.add\(contact\) ⇒ `Promise ` + +邀请好友加入群聊。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) +> +> 参照 [网页版微信封闭群界面](https://github.com/wechaty/wechaty/issues/1441) + +| Param | Type | +| :--- | :--- | +| contact | `Contact` | + +#### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any contact in your wechat +const room = await bot.Room.find({topic: 'wechat'}) // change 'wechat' to any room topic in your wechat +if (room) { + try { + await room.add(contact) + } catch(e) { + console.error(e) + } +} +``` + +### room.del\(contact\) ⇒ `Promise ` + +将好友移出群聊,这个功能仅在机器人是群主的时候会生效。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) +> +> 参照 [网页版微信封闭群界面](https://github.com/wechaty/wechaty/issues/1441) + +| Param | Type | +| :--- | :--- | +| contact | `Contact` | + +#### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'wechat'}) // change 'wechat' to any room topic in your wechat +const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any room member in the room you just set +if (room) { + try { + await room.del(contact) + } catch(e) { + console.error(e) + } +} +``` + +### room.quit\(\) ⇒ `Promise ` + +机器人主动退群。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +#### 示例 + +```javascript +await room.quit() +``` + +### room.topic\(\[newTopic\]\) ⇒ `Promise ` + +设置 / 获取 群名称。 + +| Param | Type | Description | +| :--- | :--- | :--- | +| \[newTopic\] | `string` | If set this para, it will change room topic. | + +#### 示例 \(当你在群里说话的时候,打印群名称\) + +```javascript +const bot = new Wechaty() +bot +.on('message', async m => { + const room = m.room() + if (room) { + const topic = await room.topic() + console.log(`room topic is : ${topic}`) + } +}) +.start() +``` + +#### 示例 _\(当你在群内说话的时候,机器人修改群名称\)_ + +```javascript +const bot = new Wechaty() +bot +.on('message', async m => { + const room = m.room() + if (room) { + const oldTopic = await room.topic() + await room.topic('change topic to wechaty!') + console.log(`room topic change from ${oldTopic} to ${room.topic()}`) + } +}) +.start() +``` + +### room.announce\(\[text\]\) ⇒ `Promise ` + +设置 / 获取 群公告。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +| Param | Type | Description | +| :--- | :--- | :--- | +| \[text\] | `string` | If set this para, it will change room announce. | + +#### 示例 \(当你在群里说话的时候,打印群公告\) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'your room'}) +const announce = await room.announce() +console.log(`room announce is : ${announce}`) +``` + +#### 示例 \(当你在群里说话的时候,修改群公告\) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'your room'}) +const oldAnnounce = await room.announce() +await room.announce('change announce to wechaty!') +console.log(`room announce change from ${oldAnnounce} to ${room.announce()}`) +``` + +### room.qrcode\(\) ⇒ `Promise ` + +获取群二维码,用户可以通过扫描这个二维码加入群聊。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +### room.alias\(contact\) ⇒ `Promise ` + +获取这个联系人在群内的群昵称。 + +| Param | Type | +| :--- | :--- | +| contact | `Contact` | + +#### 示例 + +```javascript +const bot = new Wechaty() +bot +.on('message', async m => { + const room = m.room() + const contact = m.from() + if (room) { + const alias = await room.alias(contact) + console.log(`${contact.name()} alias is ${alias}`) + } +}) +.start() +``` + +### room.has\(contact\) ⇒ `Promise ` + +检查群内是否有这个群成员。 + +| Param | Type | +| :--- | :--- | +| contact | `Contact` | + +#### 示例 _\(检查'lijiarui'是否在'wechaty'群\)_ + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const contact = await bot.Contact.find({name: 'lijiarui'}) // change 'lijiarui' to any of contact in your wechat +const room = await bot.Room.find({topic: 'wechaty'}) // change 'wechaty' to any of the room in your wechat +if (contact && room) { + if (await room.has(contact)) { + console.log(`${contact.name()} is in the room wechaty!`) + } else { + console.log(`${contact.name()} is not in the room wechaty!`) + } +} +``` + +### room.memberAll\(\[query\]\) ⇒ `Promise ` + +根据 query 获取群内所有的群成员列表。如果没有设置query,返回所有的群成员信息。 + +#### 定义 + +* `name` 微信联系人自己设置的昵称,等于`Contact.name()` +* `roomAlias` 微信联系人自己在群内设置的昵称 +* `contactAlias` 机器人给微信联系人设置的,等于`Contact.alias()` + +**Kind**: [`Room`](room.md#Room)实例方法 + +| Param | Type | Description | +| :--- | :--- | :--- | +| \[query\] | [`RoomMemberQueryFilter`](room.md#RoomMemberQueryFilter) \| `string` | 1. RoomMemberQueryFilter 可通过 name, roomAlias, contactAlias 查找指定的群成员。 2. 当memberAll(name) 的参数为string 类型的时候, 返回所有找到的群成员。这里面的name 包括上面定义的name, roomAlias, contactAlias。 | + +#### 示例 + +```javascript +const memberList: Conatct[] = await room.memberAll() +console.log(`room all member list: `, memberList) + +const memberContactList: Conatct[] = await room.memberAll(`abc`) +console.log(`contact list with all name, room alias, alias are abc:`, memberContactList) +``` + +### room.member\(queryArg\) ⇒ `Promise ` + +根据 query 获取群内的群成员。 + +| Param | Type | Description | +| :--- | :--- | :--- | +| queryArg | [`RoomMemberQueryFilter`](room.md#RoomMemberQueryFilter) \| `string` | RoomMemberQueryFilter 可通过 name, roomAlias, contactAlias 查找指定的群成员。 | + +#### 示例 \(用名字找member\) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'wechaty'}) // change 'wechaty' to any room name in your wechat +if (room) { + const member = await room.member('lijiarui') // change 'lijiarui' to any room member in your wechat + if (member) { + console.log(`wechaty room got the member: ${member.name()}`) + } else { + console.log(`cannot get member in wechaty room!`) + } +} +``` + +#### 示例 \(用MemberQueryFilter找member\) + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const room = await bot.Room.find({topic: 'wechaty'}) // change 'wechaty' to any room name in your wechat +if (room) { + const member = await room.member({name: 'lijiarui'}) // change 'lijiarui' to any room member in your wechat + if (member) { + console.log(`wechaty room got the member: ${member.name()}`) + } else { + console.log(`cannot get member in wechaty room!`) + } +} +``` + +### room.owner\(\) ⇒ `Contact` \| `null` + +获取群主的信息。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +#### 示例 + +```javascript +const owner = room.owner() +``` + +### room.avatar\(\) ⇒ `Promise ` + +获取群头像的信息。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +#### 示例 + +```javascript +const owner = room.avatar() +``` + +## 静态方法 + +### Room.create\(contactList, \[topic\]\) ⇒ [`Promise `](room.md#Room) + +创建群聊。 + +| Param | Type | +| :--- | :--- | +| contactList | `Array` | +| \[topic\] | `string` | + +#### 示例 _\(Creat a room with 'lijiarui' and 'juxiaomi', the room topic is 'ding - created'\)_ + +```javascript +const helperContactA = await Contact.find({ name: 'lijiarui' }) // change 'lijiarui' to any contact in your wechat +const helperContactB = await Contact.find({ name: 'juxiaomi' }) // change 'juxiaomi' to any contact in your wechat +const contactList = [helperContactA, helperContactB] +console.log('Bot', 'contactList: %s', contactList.join(',')) +const room = await Room.create(contactList, 'ding') +console.log('Bot', 'createDingRoom() new ding room created: %s', room) +await room.topic('ding - created') +await room.say('ding - created') +``` + +### Room.findAll\(\[query\]\) ⇒ `Promise ` + +通过 {topic: string \| RegExp}, 查找群,返回找到的所有群的数组。 + +| Param | Type | +| :--- | :--- | +| \[query\] | [`RoomQueryFilter`](room.md#RoomQueryFilter) | + +#### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in +const roomList = await bot.Room.findAll() // get the room list of the bot +const roomList = await bot.Room.findAll({topic: 'wechaty'}) // find all of the rooms with name 'wechaty' +``` + +### Room.find\(query\) ⇒ `Promise ` + +通过 {topic: string \| RegExp},查找群,如果找到多个群,返回找到的第一个群。 + +| Param | Type | +| :--- | :--- | +| query | [`RoomQueryFilter`](room.md#RoomQueryFilter) | + +#### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +// after logged in... +const roomList = await bot.Room.find() +const roomList = await bot.Room.find({topic: 'wechaty'}) +``` + +## Typedefs + +## RoomQueryFilter + +查找群的过滤器,{topic: string \| RegExp}. + +### Properties + +| 名字 | 类型 | +| :--- | :--- | +| topic | `string` | + +## RoomEventName + +群事件的类型 + +### Properties + +| 名字 | 类型 | 描述 | +| :--- | :--- | :--- | +| join | `string` | 当有人入群的时候,会触发这个事件。 | +| topic | `string` | 当有人修改群名称的时候,会触发这个事件。 | +| leave | `string` | 当有人离群的时候,会触发这个事件。如果是用户主动离群,是无法获取到这个事件的。 | + +## RoomEventFunction + +### Properties + +| Name | Type | Description | +| :--- | :--- | :--- | +| room-join | `function` | \(this: Room, inviteeList: Contact\[\] , inviter: Contact\) => void | +| room-topic | `function` | \(this: Room, topic: string, oldTopic: string, changer: Contact\) => void | +| room-leave | `function` | \(this: Room, leaver: Contact\) => void | + +## RoomMemberQueryFilter + +通过Room.member\(\)搜索群成员的过滤器。 + +### Properties + +| Name | Type | Description | +| :--- | :--- | :--- | +| name | `string` | 通过用户的昵称查找群成员,这里面的name 等于`Contact.name()` | +| roomAlias | `string` | 通过用户设置的群昵称查找群成员 | +| contactAlias | `string` | 通过机器人给用户设置的备注查找群成员,这里面的contactAlias 等于 `Contact.alias()`. [更多](https://github.com/wechaty/wechaty/issues/365) | \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md new file mode 100644 index 00000000000..f7685dbd86d --- /dev/null +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md @@ -0,0 +1,18 @@ +## Classes + +### Wechaty + +Wechaty 的构造类用于构造 Wechaty 实例。 + +一个Wechaty Bot 代表着一个微信的客户端,他取决于你具体使用哪一个Puppet。 + +* **web-wechat** - 当使用Puppet-Puppeteer 或 Puppet-wechat4u +* **ipad-wechat** - 当使用Puppet-padchat +* **ios-wechat** - 当使用Puppet-ioscat + +了解puppet及其用途,请访问以下链接- + +### [What is a Puppet in Wechaty](https://github.com/wechaty/wechaty-getting-started/wiki/FAQ-EN#31-what-is-a-puppet-in-wechaty)? + +> 如果您想知道如何发送消息,请参阅Message +> 如果您想了解如何获得联系,请参阅Contact \ No newline at end of file diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md index 109af99c209..e3f5d8e1da1 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md @@ -2,63 +2,380 @@ title: Wechaty --- -- [Class: WechatyBuilder](#class-wechatybuilder) - - [Static method: WechatyBuilder.build(options?: WechatyOptions)](#static-method-wechatybuilderbuildoptions-wechatyoptions) - - [Static method: WechatyBuilder.singleton(options?: WechatyOptions)](#static-method-wechatybuildersingletonoptions-wechatyoptions) - - [Static method: WechatyBuilder.valid(target: any)](#static-method-wechatybuildervalidtarget-any) -- [Class: Wechaty](#class-wechaty) - - [wechaty.start()](#wechatystart) - - [wechaty.say()](#wechatysaysayable-sayable) - - [wechaty.publish(post: PostInterface)](#wechatypublishpost-postinterface) +一个Wechaty Bot代表着一个微信的客户端,他取决于你具体使用哪一个Puppet。 -## Class: WechatyBuilder +## Classes -Wechaty 的构造类用于构造 Wechaty 实例。 +[Wechaty](wechaty.md#Wechaty) -### Static method: WechatyBuilder.build(options?: WechatyOptions) +一个Wechaty Bot代表着一个微信的客户端,他取决于你具体使用哪一个Puppet。 -返回 Wechaty 实例。 +* **web-wechat** - 当使用Puppet-Puppeteer 或 Puppet-wechat4u +* **ipad-wechat** - 当使用Puppet-padchat +* **ios-wechat** - 当使用Puppet-ioscat -根据 option 构造一个 Wechaty 实例。 +了解puppet及其用途,请访问以下链接- -示例: +* [What is a Puppet in Wechaty](https://github.com/wechaty/wechaty-getting-started/wiki/FAQ-EN#31-what-is-a-puppet-in-wechaty) -```ts -import { WechatyBuilder } from 'wechaty' +> 如果您想知道如何发送消息,请参阅 [Message](wechaty.md#Message) +> 如果您想了解如何获得联系,请参阅 [Contact](wechaty.md#Contact) -WechatyBuilder.build(options) // 在单例模式使用 instance() - .on('scan', (url, status) => console.log(`Scan QR Code to login: ${status}\n${url}`)) - .on('login', user => console.log(`User ${user} logged in`)) - .on('message', message => console.log(`Message: ${message}`)) - .start() +**Kind**: global class + +* [Wechaty](wechaty.md#Wechaty) + * [new Wechaty\(\[options\]\)](wechaty.md#new_Wechaty_new) + * _instance_ + * [.on\(event, listener\)](wechaty.md#Wechaty+on) ⇒ [`Wechaty`](wechaty.md#Wechaty) + * [.start\(\)](wechaty.md#Wechaty+start) ⇒ `Promise ` + * [.stop\(\)](wechaty.md#Wechaty+stop) ⇒ `Promise ` + * [.logout\(\)](wechaty.md#Wechaty+logout) ⇒ `Promise ` + * [.logonoff\(\)](wechaty.md#Wechaty+logonoff) ⇒ `boolean` + * [.userSelf\(\)](wechaty.md#Wechaty+userSelf) ⇒ `ContactSelf` + * [.say\(textOrContactOrFileOrUrl\)](wechaty.md#Wechaty+say) ⇒ `Promise ` + * _static_ + * [.instance\(\[options\]\)](wechaty.md#Wechaty.instance) + +### new Wechaty\(\[options\]\) + +创建一个 Wechaty 的实例。 + +| Param | Type | Default | +| :--- | :--- | :--- | +| \[options\] | [`WechatyOptions`](wechaty.md#WechatyOptions) | `{}` | + +**Example** _\(世界上最短的对话机器人代码\)_ + +```javascript +import { Wechaty } from 'wechaty' +const bot = new Wechaty() +bot.on('scan', (qrcode, status) => console.log(['https://api.qrserver.com/v1/create-qr-code/?data=',encodeURIComponent(qrcode),'&size=220x220&margin=20',].join(''))) +bot.on('login', user => console.log(`User ${user} logined`)) +bot.on('message', message => console.log(`Message: ${message}`)) +bot.start() +``` + +### wechaty.on\(event, listener\) ⇒ [`Wechaty`](wechaty.md#Wechaty) + +当机器人收到消息,会触发一个事件,一些简单的事件介绍如下: + +* **scan**: 当机器人需要扫码登录的时候,会触发这个事件,当手机扫码登录后,机器人就可以登录进去了。 +* **login**: 当机器人登陆成功后,会触发这个事件。 +* **logout**: 当机器人退出登陆的时候,会触发到这个事件。 +* **message**: 当有新消息的时候会触发这个事件。 + +更多在 [WechatyEventName](wechaty.md#WechatyEventName) + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 +**Returns**: [`Wechaty`](wechaty.md#Wechaty) + +| Param | Type | Description | +| :--- | :--- | :--- | +| event | [`WechatyEventName`](wechaty.md#WechatyEventName) | Emit WechatyEvent | +| listener | [`WechatyEventFunction`](wechaty.md#WechatyEventFunction) | Depends on the WechatyEvent | + +**示例** _\(Event:scan\)_ + +```javascript +bot.on('scan', (url, code) => { + console.log(`[${code}] Scan ${url} to login.` ) +}) +``` + +**示例** _\(Event:login \)_ + +```javascript +bot.on('login', (user) => { + console.log(`user ${user} login`) +}) +``` + +**示例** _\(Event:logout \)_ + +```javascript +bot.on('logout', (user) => { + console.log(`user ${user} logout`) +}) +``` + +**示例** _\(Event:message \)_ + +```javascript +wechaty.on('message', (message) => { + console.log(`message ${message} received`) +}) +``` + +**示例** _\(Event:friendship \)_ + +```javascript +bot.on('friendship', async (friendship) => { + const contact = friendship.contact() + if (friendship.type() === bot.Friendship.Type.Receive) { // 1.接收新友谊请求 + let result = await friendship.accept() + if (result) { + console.log(`Request from ${contact.name()} is accept succesfully!`) + } else { + console.log(`Request from ${contact.name()} failed to accept!`) + } + } else if (friendship.type() === bot.Friendship.Type.Confirm) { // 2.确认友谊请求 + console.log(`New friendship confirmed with ${contact.name()}`) + } +}) +``` + +**示例** _\(Event:room-join \)_ + +```javascript +bot.on('room-join', async (room, inviteeList, inviter) => { + const nameList = inviteeList.map(c => c.name()).join(',') + console.log(`Room ${await room.topic()} got new member ${nameList}, invited by ${inviter}`) +}) +``` + +**示例** _\(Event:room-leave \)_ + +```javascript +bot.on('room-leave', async (room, leaverList, remover) => { + const nameList = leaverList.map(c => c.name()).join(',') + console.log(`Room ${await room.topic()} lost member ${nameList}, the remover is: ${remover}`) +}) +``` + +**示例** _\(Event:room-topic \)_ + +```javascript +bot.on('room-topic', async (room, topic, oldTopic, changer) => { + console.log(`Room ${await room.topic()} topic changed from ${oldTopic} to ${topic} by ${changer.name()}`) +}) +``` + +**示例** _\(Event:room-invite \)_ + +```javascript +bot.on('room-invite', async roomInvitation => { + try { + console.log(`received room-invite event.`) + await roomInvitation.accept() + } catch (e) { + console.error(e) + } +} +``` + +**示例** _\(Event:error \)_ + +```javascript +bot.on('error', (error) => { + console.error(error) +}) +``` + +### wechaty.start\(\) ⇒ `Promise ` + +启动机器人 +> 备注:机器人所有的操作必须在这个函数执行完成之后。 + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 + +#### 示例 + +```javascript +await bot.start() ``` -### Static method: WechatyBuilder.singleton(options?: WechatyOptions) +### wechaty.stop\(\) ⇒ `Promise ` + +停止机器人 + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 + +#### 示例 + +```javascript +await bot.stop() +``` + +### wechaty.logout\(\) ⇒ `Promise ` + +退出机器人 + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 + +#### 示例 + +```javascript +await bot.logout() +``` + +### wechaty.logonoff\(\) ⇒ `boolean` + +获取机器人logon/logoff 的状态 + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 + +#### 示例 + +```javascript +if (bot.logonoff()) { + console.log('Bot logined') +} else { + console.log('Bot not logined') +} +``` + +### wechaty.userSelf\(\) ⇒ `ContactSelf` + +获取当前机器人的所有信息 + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 + +#### 示例 + +```javascript +const contact = bot.userSelf() +console.log(`Bot is ${contact.name()}`) +``` + +### wechaty.say\(text或Contact或File或Url\) ⇒ `Promise ` + +机器人自己给自己发消息。 + +> 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 + +| Param | Type | Description | +| :--- | :--- | :--- | +| textOrContactOrFileOrUrl | `string` \| `Contact` \| `FileBox` \| `UrlLink` | 发送文本、联系人名片或者文件给机器人自己。可以使用 [FileBox](https://www.npmjs.com/package/file-box) 来发送文件 | + +#### 示例 + +```javascript +const bot = new Wechaty() +await bot.start() +// 登录后 + +// 1. 机器人为自己发消息 +await bot.say('hello!') + +// 2. 机器人为自己发contact +const contact = bot.Contact.load('contactId') +await bot.say(contact) + +// 3. 机器人为自己发照片url +import { FileBox } from 'file-box' +const fileBox = FileBox.fromUrl('https://wechaty.github.io/wechaty/images/bot-qr-code.png') +await bot.say(fileBox) + +// 4. 机器人为自己发文件 +import { FileBox } from 'file-box' +const fileBox = FileBox.fromFile('/tmp/text.jpg') +await bot.say(fileBox) + +// 5. 机器人为自己发链接 +const linkPayload = new UrlLink({ + description : 'WeChat Bot SDK for Individual Account, Powered by TypeScript, Docker, and Love', + thumbnailUrl: 'https://avatars0.githubusercontent.com/u/25162437?s=200&v=4', + title : 'Welcome to Wechaty', + url : 'https://github.com/wechaty/wechaty', +}) +await bot.say(linkPayload) +``` + +### Wechaty.instance\(\[options\]\) + +获取Wechaty的全局实例。 + +**Kind**: [`Wechaty`](wechaty.md#Wechaty)的静态方法 + +| Param | Type | Default | +| :--- | :--- | :--- | +| \[options\] | [`WechatyOptions`](wechaty.md#WechatyOptions) | `{}` | + +**示例** + +```javascript +import { Wechaty } from 'wechaty' + +Wechaty.instance() // Global instance +.on('scan', (url, code) => console.log(`Scan QR Code to login: ${code}\n${url}`)) +.on('login', user => console.log(`User ${user} logined`)) +.on('message', message => console.log(`Message: ${message}`)) +.start() +``` + +## PuppetName + +Wechaty中的Puppet是一个用于实现协议插件的抽象类。插件是帮助微信控制微信的组件\(这就是我们称之为puppet的原因\). 这些插件被命名为PuppetXXX,例如: + +* [PuppetPuppeteer](https://github.com/wechaty/wechaty-puppet-puppeteer) +* [PuppetPadchat](https://github.com/lijiarui/wechaty-puppet-padchat) -返回 Wechaty 实例。 +**Kind**: global typedef +**Properties** -根据 option 构造一个单例模式的 Wechaty 实例。 +| 名字 | 类型 | 描述 | +| :--- | :--- | :--- | +| wechat4u | `string` | 默认的puppet,使用 [wechat4u](https://github.com/nodeWechat/wechat4u) 来控制 [WeChat Web API](https://wx.qq.com/) | +| padchat | `string` | 使用WebSocket 协议链接一个协议服务器,来控制iPad 微信。 | +| puppeteer | `string` | 使用 [google puppeteer](https://github.com/GoogleChrome/puppeteer) 来控制 [WeChat Web API](https://wx.qq.com/) | +| mock | `string` | 为单元测试提供模拟调用的Puppet | -### Static method: WechatyBuilder.valid(target: any) +## WechatyOptions -返回 target 是否是 Wechaty 实例。 +创建 Wechaty 实例的可选参数类型。 -## Class: Wechaty +**Kind**: global typedef +**Properties** -主要的 bot 类。 +| 名字 | 类型 | 描述 | +| :--- | :--- | :--- | +| profile | `string` | Wechaty 机器人的名称. 当你按照下面的方式设置的时候: `new Wechaty({profile: 'wechatyName'})` 他会自动生成一个叫做`wechatyName.memory-card.json`的文件 。这个文件会存储机器人的登陆信息。如果这个文件有效,启动wechaty的时候,你不需要扫码登陆就能自动登陆机器人\(只对wechaty-puppet-padchat有效\)。 这个名字在启动机器人的时候,是可以通过环境变量WECHATY_NAME设置的,如:`WECHATY_NAME="wechatyName" node bot.jsWechaty` [更多](https://github.com/wechaty/wechaty/issues/2049) | +| puppet | `PuppetModuleName` \| `Puppet` | 使用puppet名称指定相关puppet或者直接传入puppet实例作为Wechaty底层插件, 了解更多puppet信息 | +| puppetOptions | `Partial.` | Puppet TOKEN | +| ioToken | `string` | Io TOKEN | -一个 bot 是指一个代表了某个特定即时通讯软件的实力,根据使用的 puppet 不同而有所区别。 +## WechatyEventName -### wechaty.start() +Wechaty 事件的类型 -启动 bot 。 +**Kind**: global typedef +**Properties** -### wechaty.say(sayable: Sayable) +| Name | Type | Description | +| :--- | :--- | :--- | +| error | `string` | 当机器人内部出错的时候会触发error 事件。 | +| login | `string` | 当机器人成功登陆后,会触发login 事件,并会在事件中传递当前登陆机器人的信息。 | +| logout | `string` | 当机器人检测到登出的时候,会触发logout 事件,并会在事件中传递机器人的信息。 | +| heartbeat | `string` | 获取机器人的心跳。 | +| friendship | `string` | 当有人给机器人发好友请求的时候会触发这个事件。 | +| message | `string` | 当机器人收到消息的时候会触发这个事件。 | +| ready | `string` | 当所有数据加载完成后,会触发这个事件。在wechaty-puppet-padchat 中,它意味着已经加载完成Contact 和Room 的信息。 | +| room-join | `string` | 当有人进入微信群的时候会触发这个事件。机器人主动进入某个微信群,t那个样会触发这个事件。 | +| room-topic | `string` | 当有人修改群名称的时候会触发这个事件。 | +| room-leave | `string` | 当机器人把群里某个用户移出群聊的时候会触发这个时间。用户主动退群是无法检测到的。 | +| room-invite | `string` | 当收到群邀请的时候,会触发这个事件。具体请RoomInvitation | +| scan | `string` | 当机器人需要扫码登陆的时候会触发这个事件。 建议你安装 qrcode-terminal\(运行 npm install qrcode-terminal\)这个包,这样你可以在命令行中直接看到二维码。 | -对 bot 的当前用户发送消息。 +## WechatyEventFunction -### wechaty.publish(post: PostInterface) +Wechaty 事件的函数 -返回一个 postInterface 或者 void ,根据 puppet 不同有所区别。 +**Kind**: global typedef +**Properties** -发送一条朋友圈,详情请参考 Post 部分。(编写中) +| 名字 | 类型 | 描述 | +| :--- | :--- | :--- | +| error | `function` | \(this: Wechaty, error: Error\) => void callback function | +| login | `function` | \(this: Wechaty, user: ContactSelf\)=> void | +| logout | `function` | \(this: Wechaty, user: ContactSelf\) => void | +| scan | `function` | \(this: Wechaty, url: string, code: number\) => void | +| heartbeat | `function` | \(this: Wechaty, data: any\) => void | +| friendship | `function` | \(this: Wechaty, friendship: Friendship\) => void | +| message | `function` | \(this: Wechaty, message: Message\) => void | +| ready | `function` | \(this: Wechaty\) => void | +| room-join | `function` | \(this: Wechaty, room: Room, inviteeList: Contact\[\], inviter: Contact\) => void | +| room-topic | `function` | \(this: Wechaty, room: Room, newTopic: string, oldTopic: string, changer: Contact\) => void | +| room-leave | `function` | \(this: Wechaty, room: Room, leaverList: Contact\[\]\) => void | +| room-invite | `function` | \(this: Wechaty, room: Room, leaverList: Contact\[\]\) => void | From 35657c53ed662143569b153f1aea8172f2f29d73 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:29:55 +0800 Subject: [PATCH 02/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../i18n/zh/docusaurus-plugin-content-docs/current/api/room.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md index 593707b652e..e3620f0d2c9 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md @@ -14,7 +14,7 @@ title: Room | 名称 | 类型 | 描述 | | :--- | :--- | :--- | -| id | `string` | 获取群id。这个id 是否是永久不变的id 取决于使用哪一个puppet,具体 查看puppet兼容性清单,参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) | +| id | `string` | 获取群ID。这个ID 是否是永久不变的ID 取决于使用哪一个puppet,具体 查看puppet兼容性清单,参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) | ## Global class `Room` From da09d62f340654a601a742e790dc3c6203cca815 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:30:07 +0800 Subject: [PATCH 03/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../zh/docusaurus-plugin-content-docs/current/api/friendship.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md index f11bbb9a2df..3fc4216bfce 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md @@ -20,7 +20,7 @@ Wechaty机器人允许你通过其名为`Friendship`的全球类结交朋友。 |------------------|------------------| | accept() | `Promise (void)` | | hello() | `string` | -| contact() | `contact` | +| contact() | `Contact` | | type() | `Friendshiptype` | ### 静态方法 From 4f9ce940a2045368f12db4e14ba736894f6e2108 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:30:21 +0800 Subject: [PATCH 04/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../current/api/wechaty-class.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md index f7685dbd86d..990b487f69b 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md @@ -6,9 +6,9 @@ Wechaty 的构造类用于构造 Wechaty 实例。 一个Wechaty Bot 代表着一个微信的客户端,他取决于你具体使用哪一个Puppet。 -* **web-wechat** - 当使用Puppet-Puppeteer 或 Puppet-wechat4u -* **ipad-wechat** - 当使用Puppet-padchat -* **ios-wechat** - 当使用Puppet-ioscat +* **web-WeChat** - 当使用Puppet-Puppeteer 或 Puppet-wechat4u +* **iPad-WeChat** - 当使用Puppet-padchat +* **iOS-WeChat** - 当使用Puppet-ioscat 了解puppet及其用途,请访问以下链接- From a901f51882c824ba5fc50b53f560c4ec7df7440a Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:30:31 +0800 Subject: [PATCH 05/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../zh/docusaurus-plugin-content-docs/current/api/friendship.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md index 3fc4216bfce..ae03471f93e 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md @@ -21,7 +21,7 @@ Wechaty机器人允许你通过其名为`Friendship`的全球类结交朋友。 | accept() | `Promise (void)` | | hello() | `string` | | contact() | `Contact` | -| type() | `Friendshiptype` | +| type() | `FriendshipType` | ### 静态方法 From 1d2322efb1e616e186fac843e1ea15838db74e57 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:30:41 +0800 Subject: [PATCH 06/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../zh/docusaurus-plugin-content-docs/current/api/contact.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md index 831b6ff7e39..01dd7e6826f 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -17,7 +17,7 @@ title: Contact Class | 名称 | 类型 | 描述 | | :--- | :--- | :--- | -| id | `string` | 获取联系人id,这个id 是否为永久唯一id 取决于您使用什么puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) | +| id | `string` | 获取联系人ID,这个ID 是否为永久唯一ID 取决于您使用什么puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) | ## Global Class `Contact` From 017a7d60785ebd7953456a2b903e0b5ef21fc1c2 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:31:36 +0800 Subject: [PATCH 07/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../zh/docusaurus-plugin-content-docs/current/api/contact.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md index 01dd7e6826f..7ddea004beb 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -25,7 +25,7 @@ title: Contact Class | 实例方法 | 返回类型 | |--------------------------------------|-----------------------------------------------------------------------| -| say(text 或 Contact 或 File 或 Url) | `Promise` | +| say(text 或 Contact 或 File 或 URL) | `Promise` | | name() | `String` | | alias(newAlias) | `Promise` | | friend() | `Boolean 或 null` | From a4ae0bbfed735602eb12efc27abe6888aeb8853f Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:31:47 +0800 Subject: [PATCH 08/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../zh/docusaurus-plugin-content-docs/current/api/contact.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md index 7ddea004beb..7c4c367f6ec 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -42,7 +42,7 @@ title: Contact Class | 静态方法 | 返回类型 | |---------------------------|-----------------------------| | find(query) | `Promise ` | -| findAll(Query Arguements) | `Promise ` | +| findAll(Query Arguments) | `Promise ` | ### contact.say\(textOrContactOrFileOrUrlLinkOrMiniProgram\) ⇒ `Promise ` From b7f04ecf3eb2e628b921a6d44ebbf1b35e2164b0 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:32:05 +0800 Subject: [PATCH 09/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../current/api/contact-self.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md index 8f4402f79b1..a719d193860 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md @@ -37,19 +37,6 @@ bot.on('login', async user => { await file.toFile(name, true) console.log(`Save bot avatar: ${user.name()} with avatar file: ${name}`) }) -``` - -**示例** _\(SET the avatar for a bot\)_ - -```javascript -import { FileBox } from 'file-box' -bot.on('login', user => { - console.log(`user ${user} login`) - const fileBox = FileBox.fromUrl('https://wechaty.github.io/wechaty/images/bot-qr-code.png') - await user.avatar(fileBox) - console.log(`Change bot avatar successfully!`) -}) -``` ### contactSelf.qrcode\(\) ⇒ `Promise ` From a96b7d44c17526645e99e600c4048467fda0342a Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:32:18 +0800 Subject: [PATCH 10/19] Update docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../zh/docusaurus-plugin-content-docs/current/api/contact.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md index 7c4c367f6ec..2863f66ea7f 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -123,7 +123,7 @@ const name = contact.name() | Param | Type | | :--- | :--- | -| newAlias | `none` \| `string` \| `null` | +| newAlias | `undefined` \| `string` \| `null` | ### 示例 \( GET contact的备注, return {\(Promise<string \| null>\)}\) From 15a2b3e009ad92faf3398e8d2905eae8af0ac316 Mon Sep 17 00:00:00 2001 From: comeonzhj Date: Fri, 8 Mar 2024 17:40:15 +0800 Subject: [PATCH 11/19] formatting fix --- .../current/api/contact-self.md | 2 +- .../current/api/contact.md | 2 +- .../current/api/friendship.md | 12 ++++++------ .../current/api/message.md | 3 +-- .../current/api/room-invitation.md | 2 +- .../current/api/room.md | 2 +- .../current/api/wechaty-class.md | 2 +- .../current/api/wechaty.md | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md index 8f4402f79b1..c40109b629a 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md @@ -114,4 +114,4 @@ bot.on('login', async user => { console.error('change name failed', e) } }) -``` \ No newline at end of file +``` diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md index 831b6ff7e39..f355708f3fc 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -304,4 +304,4 @@ const contactList = await bot.Contact.findAll({ alias: 'lijiarui' }) // find all | Name | Type | Description | | :--- | :--- | :--- | | name | `string` | 用户自己设置的昵称叫做name | -| alias | `string` | 机器人或者其他人给这个用户设置的昵称叫做alias [更多](https://github.com/wechaty/wechaty/issues/365) | \ No newline at end of file +| alias | `string` | 机器人或者其他人给这个用户设置的昵称叫做alias [更多](https://github.com/wechaty/wechaty/issues/365) | diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md index f11bbb9a2df..31910e8af1a 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/friendship.md @@ -33,7 +33,7 @@ Wechaty机器人允许你通过其名为`Friendship`的全球类结交朋友。 通过好友请求。 -#### 示例 +#### 示例 ```javascript const bot = new Wechaty() @@ -65,7 +65,7 @@ bot.on('friendship', async friendship => { 获取对方发送好友请求的验证信息。 -**示例 ** _\(如内容是 \`ding\`, 接受好友请求\)_ +**示例** _\(如内容是 \`ding\`, 接受好友请求\)_ ```javascript const bot = new Wechaty() @@ -86,7 +86,7 @@ bot.on('friendship', async friendship => { 获取发送好友请求的联系人。 -#### 示例 +#### 示例 ```javascript const bot = new Wechaty() @@ -127,14 +127,14 @@ bot.on('friendship', async friendship => { ### Friendship.search\(phone\) ⇒ `Promise ` -该方法通过电话号码搜索联系人并获取联系人。 +该方法通过电话号码搜索联系人并获取联系人。 > 最佳实践:每分钟加1次,如果发送的过于频繁,你可能会被封号,每天能添加的好友数量是有上限的。 | Param | Type | Description | | :--- | :--- | :--- | | phone | `number` | 搜索电话号码 | -#### 示例 +#### 示例 ```javascript const phone = '131xxx1234' @@ -186,4 +186,4 @@ if (message.type() === bot.Message.Type.Contact) { } await bot.Friendship.add(contact, options) } -``` \ No newline at end of file +``` diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md index 6958b15fee4..2682b4d6b0c 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/message.md @@ -151,7 +151,6 @@ bot 回复多媒体、微信名片、文本或者链接给这条消息的发送者。 - | Param | Type | Description | | :--- | :--- | :--- | | text 或 Contact 或 File 或 UrlLink 或 MiniProgram | `string` \| `Contact` \| `FileBox` \| `UrlLink` \| `MiniProgram` | 发送文本、名片或者文件 可以使用 [FileBox](https://www.npmjs.com/package/file-box) 来发送文件 | @@ -354,4 +353,4 @@ bot ### Message.findAll\(\) ⇒ `Promise ` -在缓存中找消息。 \ No newline at end of file +在缓存中找消息。 diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md index 67c93fd8d22..1eab7f6f17b 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room-invitation.md @@ -71,4 +71,4 @@ bot.on('room-invite', async roomInvitation => { ### roomInvitation.age\(\) ⇒ `Promise ` 获取入群邀请的时间间隔。 -例如:入群邀请的发送时间在`8:43:15`, 当我们在Wechaty 上收到这个信息的时间是`8:43:01`, 那么age\(\)的值为: `8:43:15 - 8:43:01 = 14 (seconds)` \ No newline at end of file +例如:入群邀请的发送时间在`8:43:15`, 当我们在Wechaty 上收到这个信息的时间是`8:43:01`, 那么age\(\)的值为: `8:43:15 - 8:43:01 = 14 (seconds)` diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md index 593707b652e..90bd86c5215 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md @@ -586,4 +586,4 @@ const roomList = await bot.Room.find({topic: 'wechaty'}) | :--- | :--- | :--- | | name | `string` | 通过用户的昵称查找群成员,这里面的name 等于`Contact.name()` | | roomAlias | `string` | 通过用户设置的群昵称查找群成员 | -| contactAlias | `string` | 通过机器人给用户设置的备注查找群成员,这里面的contactAlias 等于 `Contact.alias()`. [更多](https://github.com/wechaty/wechaty/issues/365) | \ No newline at end of file +| contactAlias | `string` | 通过机器人给用户设置的备注查找群成员,这里面的contactAlias 等于 `Contact.alias()`. [更多](https://github.com/wechaty/wechaty/issues/365) | diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md index f7685dbd86d..c2eed6538c7 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty-class.md @@ -15,4 +15,4 @@ Wechaty 的构造类用于构造 Wechaty 实例。 ### [What is a Puppet in Wechaty](https://github.com/wechaty/wechaty-getting-started/wiki/FAQ-EN#31-what-is-a-puppet-in-wechaty)? > 如果您想知道如何发送消息,请参阅Message -> 如果您想了解如何获得联系,请参阅Contact \ No newline at end of file +> 如果您想了解如何获得联系,请参阅Contact diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md index e3f5d8e1da1..928f666961f 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md @@ -293,7 +293,7 @@ await bot.say(linkPayload) | :--- | :--- | :--- | | \[options\] | [`WechatyOptions`](wechaty.md#WechatyOptions) | `{}` | -**示例** +#### 示例 ```javascript import { Wechaty } from 'wechaty' From 92fc45bed72e07c310c5a3bf2d4962c02ed73bc4 Mon Sep 17 00:00:00 2001 From: comeonzhj Date: Fri, 8 Mar 2024 17:40:35 +0800 Subject: [PATCH 12/19] 0.11.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cf5907342f5..209b3780f44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-docusaurus", - "version": "0.11.7", + "version": "0.11.8", "description": "Wechaty Official Website for Documentations", "private": true, "type": "module", From 19d4df12862e127b83976e66f8ed1457b7731e08 Mon Sep 17 00:00:00 2001 From: comeonzhj Date: Fri, 8 Mar 2024 17:46:48 +0800 Subject: [PATCH 13/19] 0.11.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 209b3780f44..59bc0d3ba1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-docusaurus", - "version": "0.11.8", + "version": "0.11.9", "description": "Wechaty Official Website for Documentations", "private": true, "type": "module", From 4390b64a45735e24dba89dfb2af9f605a9f28904 Mon Sep 17 00:00:00 2001 From: Annie Hermann Date: Sat, 9 Mar 2024 21:34:53 +0800 Subject: [PATCH 14/19] fix internal links --- docusaurus/docs/api/contact-self.md | 20 +++---- .../current/api/contact-self.md | 20 +++---- .../current/api/contact.md | 6 +-- .../current/api/room.md | 12 ++--- .../current/api/wechaty.md | 54 +++++++++---------- 5 files changed, 56 insertions(+), 56 deletions(-) diff --git a/docusaurus/docs/api/contact-self.md b/docusaurus/docs/api/contact-self.md index 59827315330..d3788b08e57 100644 --- a/docusaurus/docs/api/contact-self.md +++ b/docusaurus/docs/api/contact-self.md @@ -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 `](contact-self.md#contactselfavatarfile-⇒-promise) - * [contactSelf.qrcode\(\) ⇒ `Promise `](contact-self.md#contactselfqrcode-⇒-promise) - * [contactSelf.signature\(signature\) ⇒ `Promise `](contact-self.md#contactselfsignaturesignature) - * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](contact-self.md#contactselfname-⇒-promisestring) +* [ContactSelf](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactself) + * [intance](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactself) + * [contactSelf.avatar\(\[file\]\) ⇒ `Promise `](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactselfavatarfile-⇒-promise) + * [contactSelf.qrcode\(\) ⇒ `Promise `](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactselfqrcode-⇒-promise) + * [contactSelf.signature\(signature\) ⇒ `Promise `](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactselfsignaturesignature) + * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactselfname-⇒-promisestring) ### contactSelf.avatar\(\[file\]\) ⇒ `Promise ` GET / SET bot avatar -**Kind**: instance method of [`ContactSelf`](contact-self.md#ContactSelf) +**Kind**: instance method of [`ContactSelf`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#ContactSelf) | Param | Type | | :--- | :--- | @@ -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`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#ContactSelf) #### Example @@ -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`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#ContactSelf) | Param | Description | | :--- | :--- | @@ -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`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactself) | Param | Description | | :--- | :--- | diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md index 9602b9008b1..46b0f7f2c9a 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md @@ -10,18 +10,18 @@ title: ContactSelf **Kind**: global class -* [ContactSelf](contact-self.md#contactself) - * [intance](contact-self.md#contactself) - * [contactSelf.avatar\(\[file\]\) ⇒ `Promise `](contact-self.md#contactselfavatarfile-⇒-promise) - * [contactSelf.qrcode\(\) ⇒ `Promise `](contact-self.md#contactselfqrcode-⇒-promise) - * [contactSelf.signature\(signature\) ⇒ `Promise `](contact-self.md#contactselfsignaturesignature) - * [contactSelf.name\(\[name\]\) ⇒ `Promise | 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 `](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise) + * [contactSelf.qrcode\(\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise) + * [contactSelf.signature\(signature\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfsignaturesignature) + * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring) ### contactSelf.avatar\(\[file\]\) ⇒ `Promise ` 设置机器人的头像 -**Kind**: [`ContactSelf`](contact-self.md#ContactSelf)的实例方法 +**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)的实例方法 | Param | Type | | :--- | :--- | @@ -42,7 +42,7 @@ bot.on('login', async user => { 获取机器人的二维码。 -**Kind**: [`ContactSelf`](contact-self.md#ContactSelf)的实例方法 +**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)的实例方法 #### 示例 @@ -60,7 +60,7 @@ bot.on('login', async user => { 修改机器人签名。 -**Kind**: [`ContactSelf`](contact-self.md#ContactSelf)的实例方法 +**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)的实例方法 | Param | Description | | :--- | :--- | @@ -83,7 +83,7 @@ bot.on('login', async user => { 修改机器人昵称。 -**Kind**: [`ContactSelf`](contact-self.md#contactself)的实例方法 +**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#contactself)的实例方法 | Param | Description | | :--- | :--- | diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md index 8131186c0e1..4323e999e13 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -50,7 +50,7 @@ title: Contact Class | Param | Type | Description | | :--- | :--- | :--- | -| text或Contact或File或UrlLink或MiniProgram | `string` \| [`Contact`](contact.md#Contact) \| `FileBox` \| `UrlLink` \| `MiniProgram` | 给微信好友发送文本,联系人名片,文件或者链接。你可以使用[FileBox](https://www.npmjs.com/package/file-box) 来发送文件。| +| text或Contact或File或UrlLink或MiniProgram | `string` \| [`Contact`](/zh/docs/api/contact.md#Contact) \| `FileBox` \| `UrlLink` \| `MiniProgram` | 给微信好友发送文本,联系人名片,文件或者链接。你可以使用[FileBox](https://www.npmjs.com/package/file-box) 来发送文件。| ### 示例 @@ -259,7 +259,7 @@ const isSelf = contact.self() | Param | Type | | :--- | :--- | -| query | [`ContactQueryFilter`](contact.md#ContactQueryFilter) | +| query | [`ContactQueryFilter`](/zh/docs/api/contact.md#ContactQueryFilter) | #### 示例 @@ -281,7 +281,7 @@ const contactFindByAlias = await bot.Contact.find({ alias:"lijiarui"} ) | Param | Type | | :--- | :--- | -| queryArg | [`ContactQueryFilter`](contact.md#ContactQueryFilter) | +| queryArg | [`ContactQueryFilter`](/zh/docs/api/contact.md#ContactQueryFilter) | #### 示例 diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md index 2fb7c391550..17a60721e29 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md @@ -134,8 +134,8 @@ Return `this` - - Room for chain. | Param | Type | Description | | :--- | :--- | :--- | -| event | [`RoomEventName`](room.md#RoomEventName) | 群内事件触发 | -| listener | [`RoomEventFunction`](room.md#RoomEventFunction) | 取决于是哪一个事件 | +| event | [`RoomEventName`](/zh/docs/api/room.md#RoomEventName) | 群内事件触发 | +| listener | [`RoomEventFunction`](/zh/docs/api/room.md#RoomEventFunction) | 取决于是哪一个事件 | #### 示例 \(Event:join \) @@ -400,7 +400,7 @@ if (contact && room) { * `roomAlias` 微信联系人自己在群内设置的昵称 * `contactAlias` 机器人给微信联系人设置的,等于`Contact.alias()` -**Kind**: [`Room`](room.md#Room)实例方法 +**Kind**: [`Room`](/zh/docs/api/room.md#Room)实例方法 | Param | Type | Description | | :--- | :--- | :--- | @@ -484,7 +484,7 @@ const owner = room.avatar() ## 静态方法 -### Room.create\(contactList, \[topic\]\) ⇒ [`Promise `](room.md#Room) +### Room.create\(contactList, \[topic\]\) ⇒ [`Promise `](/zh/docs/api/room.md#Room) 创建群聊。 @@ -493,7 +493,7 @@ const owner = room.avatar() | contactList | `Array` | | \[topic\] | `string` | -#### 示例 _\(Creat a room with 'lijiarui' and 'juxiaomi', the room topic is 'ding - created'\)_ +#### 示例 _\(创造新群拉'lijiarui'和'juxiaomi', 群名称是 'ding - created'\)_ ```javascript const helperContactA = await Contact.find({ name: 'lijiarui' }) // change 'lijiarui' to any contact in your wechat @@ -512,7 +512,7 @@ await room.say('ding - created') | Param | Type | | :--- | :--- | -| \[query\] | [`RoomQueryFilter`](room.md#RoomQueryFilter) | +| \[query\] | [`RoomQueryFilter`](/zh/docs/api/room.md#RoomQueryFilter) | #### 示例 diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md index 928f666961f..3b431fda5b7 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md @@ -18,23 +18,23 @@ title: Wechaty * [What is a Puppet in Wechaty](https://github.com/wechaty/wechaty-getting-started/wiki/FAQ-EN#31-what-is-a-puppet-in-wechaty) -> 如果您想知道如何发送消息,请参阅 [Message](wechaty.md#Message) -> 如果您想了解如何获得联系,请参阅 [Contact](wechaty.md#Contact) +> 如果您想知道如何发送消息,请参阅 [Message](/zh/docs/api/wechaty.md#Message) +> 如果您想了解如何获得联系,请参阅 [Contact](/zh/docs/api/wechaty.md#Contact) **Kind**: global class -* [Wechaty](wechaty.md#Wechaty) - * [new Wechaty\(\[options\]\)](wechaty.md#new_Wechaty_new) +* [Wechaty](/zh/docs/api/wechaty.md#Wechaty) + * [new Wechaty\(\[options\]\)](/zh/docs/api/wechaty.md#new_Wechaty_new) * _instance_ - * [.on\(event, listener\)](wechaty.md#Wechaty+on) ⇒ [`Wechaty`](wechaty.md#Wechaty) - * [.start\(\)](wechaty.md#Wechaty+start) ⇒ `Promise ` - * [.stop\(\)](wechaty.md#Wechaty+stop) ⇒ `Promise ` - * [.logout\(\)](wechaty.md#Wechaty+logout) ⇒ `Promise ` - * [.logonoff\(\)](wechaty.md#Wechaty+logonoff) ⇒ `boolean` - * [.userSelf\(\)](wechaty.md#Wechaty+userSelf) ⇒ `ContactSelf` - * [.say\(textOrContactOrFileOrUrl\)](wechaty.md#Wechaty+say) ⇒ `Promise ` + * [.on\(event, listener\)](/zh/docs/api/wechaty.md#Wechaty+on) ⇒ [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty) + * [.start\(\)](/zh/docs/api//zh/docs/api/wechaty.md#Wechaty+start) ⇒ `Promise ` + * [.stop\(\)](/zh/docs/api/wechaty.md#Wechaty+stop) ⇒ `Promise ` + * [.logout\(\)](/zh/docs/api/wechaty.md#Wechaty+logout) ⇒ `Promise ` + * [.logonoff\(\)](/zh/docs/api/wechaty.md#Wechaty+logonoff) ⇒ `boolean` + * [.userSelf\(\)](/zh/docs/api/wechaty.md#Wechaty+userSelf) ⇒ `ContactSelf` + * [.say\(textOrContactOrFileOrUrl\)](/zh/docs/api/wechaty.md#Wechaty+say) ⇒ `Promise ` * _static_ - * [.instance\(\[options\]\)](wechaty.md#Wechaty.instance) + * [.instance\(\[options\]\)](/zh/docs/api/current/api/wechaty.md#Wechaty.instance) ### new Wechaty\(\[options\]\) @@ -42,7 +42,7 @@ title: Wechaty | Param | Type | Default | | :--- | :--- | :--- | -| \[options\] | [`WechatyOptions`](wechaty.md#WechatyOptions) | `{}` | +| \[options\] | [`WechatyOptions`](/zh/docs/api/api/wechaty.md#WechatyOptions) | `{}` | **Example** _\(世界上最短的对话机器人代码\)_ @@ -55,7 +55,7 @@ bot.on('message', message => console.log(`Message: ${message}`)) bot.start() ``` -### wechaty.on\(event, listener\) ⇒ [`Wechaty`](wechaty.md#Wechaty) +### wechaty.on\(event, listener\) ⇒ [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty) 当机器人收到消息,会触发一个事件,一些简单的事件介绍如下: @@ -64,15 +64,15 @@ bot.start() * **logout**: 当机器人退出登陆的时候,会触发到这个事件。 * **message**: 当有新消息的时候会触发这个事件。 -更多在 [WechatyEventName](wechaty.md#WechatyEventName) +更多在 [WechatyEventName](/zh/docs/api/wechaty.md#WechatyEventName) -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 -**Returns**: [`Wechaty`](wechaty.md#Wechaty) +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 +**Returns**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty) | Param | Type | Description | | :--- | :--- | :--- | -| event | [`WechatyEventName`](wechaty.md#WechatyEventName) | Emit WechatyEvent | -| listener | [`WechatyEventFunction`](wechaty.md#WechatyEventFunction) | Depends on the WechatyEvent | +| event | [`WechatyEventName`](/zh/docs/api/api/wechaty.md#WechatyEventName) | Emit WechatyEvent | +| listener | [`WechatyEventFunction`](/zh/docs/api/wechaty.md#WechatyEventFunction) | Depends on the WechatyEvent | **示例** _\(Event:scan\)_ @@ -176,7 +176,7 @@ bot.on('error', (error) => { 启动机器人 > 备注:机器人所有的操作必须在这个函数执行完成之后。 -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 #### 示例 @@ -188,7 +188,7 @@ await bot.start() 停止机器人 -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 #### 示例 @@ -200,7 +200,7 @@ await bot.stop() 退出机器人 -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 #### 示例 @@ -212,7 +212,7 @@ await bot.logout() 获取机器人logon/logoff 的状态 -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 #### 示例 @@ -228,7 +228,7 @@ if (bot.logonoff()) { 获取当前机器人的所有信息 -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 #### 示例 @@ -243,7 +243,7 @@ console.log(`Bot is ${contact.name()}`) > 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的实例方法 +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 | Param | Type | Description | | :--- | :--- | :--- | @@ -287,11 +287,11 @@ await bot.say(linkPayload) 获取Wechaty的全局实例。 -**Kind**: [`Wechaty`](wechaty.md#Wechaty)的静态方法 +**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的静态方法 | Param | Type | Default | | :--- | :--- | :--- | -| \[options\] | [`WechatyOptions`](wechaty.md#WechatyOptions) | `{}` | +| \[options\] | [`WechatyOptions`](/zh/docs/api/wechaty.md#WechatyOptions) | `{}` | #### 示例 From 7ad16aac2078f22fe4b8c7dd1b9465af9841ec08 Mon Sep 17 00:00:00 2001 From: Annie Hermann Date: Sat, 9 Mar 2024 21:35:30 +0800 Subject: [PATCH 15/19] 0.11.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 59bc0d3ba1a..1f885fd7a82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-docusaurus", - "version": "0.11.9", + "version": "0.11.10", "description": "Wechaty Official Website for Documentations", "private": true, "type": "module", From 80ead809c9eca05f2d79c626076a1d8bfddc4a13 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Sat, 9 Mar 2024 21:40:36 +0800 Subject: [PATCH 16/19] Update contact-self.md --- docusaurus/docs/api/contact-self.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docusaurus/docs/api/contact-self.md b/docusaurus/docs/api/contact-self.md index d3788b08e57..157b35aabe5 100644 --- a/docusaurus/docs/api/contact-self.md +++ b/docusaurus/docs/api/contact-self.md @@ -12,18 +12,18 @@ Bot itself will be encapsulated as a ContactSelf. **Kind**: global class -* [ContactSelf](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactself) - * [intance](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactself) - * [contactSelf.avatar\(\[file\]\) ⇒ `Promise `](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactselfavatarfile-⇒-promise) - * [contactSelf.qrcode\(\) ⇒ `Promise `](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactselfqrcode-⇒-promise) - * [contactSelf.signature\(signature\) ⇒ `Promise `](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactselfsignaturesignature) - * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/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 `](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise) + * [contactSelf.qrcode\(\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise) + * [contactSelf.signature\(signature\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfsignaturesignature) + * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring) ### contactSelf.avatar\(\[file\]\) ⇒ `Promise ` GET / SET bot avatar -**Kind**: instance method of [`ContactSelf`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#ContactSelf) +**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf) | Param | Type | | :--- | :--- | @@ -59,7 +59,7 @@ bot.on('login', user => { Get bot qrcode -**Kind**: instance method of [`ContactSelf`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#ContactSelf) +**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf) #### Example @@ -77,7 +77,7 @@ bot.on('login', async user => { Change bot signature -**Kind**: instance method of [`ContactSelf`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#ContactSelf) +**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf) | Param | Description | | :--- | :--- | @@ -100,7 +100,7 @@ bot.on('login', async user => { Get or change bot name. -**Kind**: instance method of [`ContactSelf`](/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md#contactself) +**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#contactself) | Param | Description | | :--- | :--- | From 49d91a151d52e4669a1a13fae99c5aa85cbc37f5 Mon Sep 17 00:00:00 2001 From: Annie Hermann <55369934+aherman3@users.noreply.github.com> Date: Sat, 9 Mar 2024 21:46:52 +0800 Subject: [PATCH 17/19] Update contact-self.md --- docusaurus/docs/api/contact-self.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docusaurus/docs/api/contact-self.md b/docusaurus/docs/api/contact-self.md index 157b35aabe5..59827315330 100644 --- a/docusaurus/docs/api/contact-self.md +++ b/docusaurus/docs/api/contact-self.md @@ -12,18 +12,18 @@ Bot itself will be encapsulated as a ContactSelf. **Kind**: global class -* [ContactSelf](/zh/docs/api/contact-self.md#contactself) - * [intance](/zh/docs/api/contact-self.md#contactself) - * [contactSelf.avatar\(\[file\]\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise) - * [contactSelf.qrcode\(\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise) - * [contactSelf.signature\(signature\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfsignaturesignature) - * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring) +* [ContactSelf](contact-self.md#contactself) + * [intance](contact-self.md#contactself) + * [contactSelf.avatar\(\[file\]\) ⇒ `Promise `](contact-self.md#contactselfavatarfile-⇒-promise) + * [contactSelf.qrcode\(\) ⇒ `Promise `](contact-self.md#contactselfqrcode-⇒-promise) + * [contactSelf.signature\(signature\) ⇒ `Promise `](contact-self.md#contactselfsignaturesignature) + * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](contact-self.md#contactselfname-⇒-promisestring) ### contactSelf.avatar\(\[file\]\) ⇒ `Promise ` GET / SET bot avatar -**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf) +**Kind**: instance method of [`ContactSelf`](contact-self.md#ContactSelf) | Param | Type | | :--- | :--- | @@ -59,7 +59,7 @@ bot.on('login', user => { Get bot qrcode -**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf) +**Kind**: instance method of [`ContactSelf`](contact-self.md#ContactSelf) #### Example @@ -77,7 +77,7 @@ bot.on('login', async user => { Change bot signature -**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf) +**Kind**: instance method of [`ContactSelf`](contact-self.md#ContactSelf) | Param | Description | | :--- | :--- | @@ -100,7 +100,7 @@ bot.on('login', async user => { Get or change bot name. -**Kind**: instance method of [`ContactSelf`](/zh/docs/api/contact-self.md#contactself) +**Kind**: instance method of [`ContactSelf`](contact-self.md#contactself) | Param | Description | | :--- | :--- | From 17a45be3f5ab5fda0e28b8c15bcac413fe07dd84 Mon Sep 17 00:00:00 2001 From: Annie Hermann Date: Sat, 9 Mar 2024 22:53:11 +0800 Subject: [PATCH 18/19] fix broken links --- .../current/api/contact-self.md | 20 +++---- .../current/api/contact.md | 6 +- .../current/api/room.md | 12 ++-- .../current/api/wechaty.md | 58 +++++++++---------- 4 files changed, 47 insertions(+), 49 deletions(-) diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md index 46b0f7f2c9a..0df5638d2ca 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact-self.md @@ -10,18 +10,18 @@ title: ContactSelf **Kind**: global class -* [ContactSelf](/zh/docs/api/contact-self.md#contactself) - * [intance](/zh/docs/api/contact-self.md#contactself) - * [contactSelf.avatar\(\[file\]\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfavatarfile-⇒-promise) - * [contactSelf.qrcode\(\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfqrcode-⇒-promise) - * [contactSelf.signature\(signature\) ⇒ `Promise `](/zh/docs/api/contact-self.md#contactselfsignaturesignature) - * [contactSelf.name\(\[name\]\) ⇒ `Promise | string`](/zh/docs/api/contact-self.md#contactselfname-⇒-promisestring) +* ContactSelf + * 实例 + * contactSelf.avatar\(\[file\]\) ⇒ `Promise ` + * contactSelf.qrcode\(\) ⇒ `Promise ` + * contactSelf.signature\(signature\) ⇒ `Promise ` + * contactSelf.name\(\[name\]\) ⇒ `Promise | string` ### contactSelf.avatar\(\[file\]\) ⇒ `Promise ` 设置机器人的头像 -**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)的实例方法 +**Kind**: `ContactSelf`的实例方法 | Param | Type | | :--- | :--- | @@ -42,7 +42,7 @@ bot.on('login', async user => { 获取机器人的二维码。 -**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)的实例方法 +**Kind**: `ContactSelf`的实例方法 #### 示例 @@ -60,7 +60,7 @@ bot.on('login', async user => { 修改机器人签名。 -**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#ContactSelf)的实例方法 +**Kind**: `ContactSelf`的实例方法 | Param | Description | | :--- | :--- | @@ -83,7 +83,7 @@ bot.on('login', async user => { 修改机器人昵称。 -**Kind**: [`ContactSelf`](/zh/docs/api/contact-self.md#contactself)的实例方法 +**Kind**: `ContactSelf`的实例方法 | Param | Description | | :--- | :--- | diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md index 4323e999e13..fe4f2bc631c 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/contact.md @@ -50,7 +50,7 @@ title: Contact Class | Param | Type | Description | | :--- | :--- | :--- | -| text或Contact或File或UrlLink或MiniProgram | `string` \| [`Contact`](/zh/docs/api/contact.md#Contact) \| `FileBox` \| `UrlLink` \| `MiniProgram` | 给微信好友发送文本,联系人名片,文件或者链接。你可以使用[FileBox](https://www.npmjs.com/package/file-box) 来发送文件。| +| text或Contact或File或UrlLink或MiniProgram | `string` \| `Contact` \| `FileBox` \| `UrlLink` \| `MiniProgram` | 给微信好友发送文本,联系人名片,文件或者链接。你可以使用[FileBox](https://www.npmjs.com/package/file-box) 来发送文件。| ### 示例 @@ -259,7 +259,7 @@ const isSelf = contact.self() | Param | Type | | :--- | :--- | -| query | [`ContactQueryFilter`](/zh/docs/api/contact.md#ContactQueryFilter) | +| query | `ContactQueryFilter` | #### 示例 @@ -281,7 +281,7 @@ const contactFindByAlias = await bot.Contact.find({ alias:"lijiarui"} ) | Param | Type | | :--- | :--- | -| queryArg | [`ContactQueryFilter`](/zh/docs/api/contact.md#ContactQueryFilter) | +| queryArg | `ContactQueryFilter` | #### 示例 diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md index 17a60721e29..2e723f4352a 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/room.md @@ -134,8 +134,8 @@ Return `this` - - Room for chain. | Param | Type | Description | | :--- | :--- | :--- | -| event | [`RoomEventName`](/zh/docs/api/room.md#RoomEventName) | 群内事件触发 | -| listener | [`RoomEventFunction`](/zh/docs/api/room.md#RoomEventFunction) | 取决于是哪一个事件 | +| event | `RoomEventName` | 群内事件触发 | +| listener | `RoomEventFunction` | 取决于是哪一个事件 | #### 示例 \(Event:join \) @@ -400,11 +400,11 @@ if (contact && room) { * `roomAlias` 微信联系人自己在群内设置的昵称 * `contactAlias` 机器人给微信联系人设置的,等于`Contact.alias()` -**Kind**: [`Room`](/zh/docs/api/room.md#Room)实例方法 +**Kind**: `Room`实例方法 | Param | Type | Description | | :--- | :--- | :--- | -| \[query\] | [`RoomMemberQueryFilter`](room.md#RoomMemberQueryFilter) \| `string` | 1. RoomMemberQueryFilter 可通过 name, roomAlias, contactAlias 查找指定的群成员。 2. 当memberAll(name) 的参数为string 类型的时候, 返回所有找到的群成员。这里面的name 包括上面定义的name, roomAlias, contactAlias。 | +| \[query\] | `RoomMemberQueryFilter` \| `string` | 1. RoomMemberQueryFilter 可通过 name, roomAlias, contactAlias 查找指定的群成员。 2. 当memberAll(name) 的参数为string 类型的时候, 返回所有找到的群成员。这里面的name 包括上面定义的name, roomAlias, contactAlias。 | #### 示例 @@ -484,7 +484,7 @@ const owner = room.avatar() ## 静态方法 -### Room.create\(contactList, \[topic\]\) ⇒ [`Promise `](/zh/docs/api/room.md#Room) +### Room.create\(contactList, \[topic\]\) ⇒ `Promise ` 创建群聊。 @@ -512,7 +512,7 @@ await room.say('ding - created') | Param | Type | | :--- | :--- | -| \[query\] | [`RoomQueryFilter`](/zh/docs/api/room.md#RoomQueryFilter) | +| \[query\] | `RoomQueryFilter` | #### 示例 diff --git a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md index 3b431fda5b7..7c8944c4250 100644 --- a/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md +++ b/docusaurus/i18n/zh/docusaurus-plugin-content-docs/current/api/wechaty.md @@ -6,8 +6,6 @@ title: Wechaty ## Classes -[Wechaty](wechaty.md#Wechaty) - 一个Wechaty Bot代表着一个微信的客户端,他取决于你具体使用哪一个Puppet。 * **web-wechat** - 当使用Puppet-Puppeteer 或 Puppet-wechat4u @@ -18,23 +16,23 @@ title: Wechaty * [What is a Puppet in Wechaty](https://github.com/wechaty/wechaty-getting-started/wiki/FAQ-EN#31-what-is-a-puppet-in-wechaty) -> 如果您想知道如何发送消息,请参阅 [Message](/zh/docs/api/wechaty.md#Message) -> 如果您想了解如何获得联系,请参阅 [Contact](/zh/docs/api/wechaty.md#Contact) +> 如果您想知道如何发送消息,请参阅Message +> 如果您想了解如何获得联系,请参阅Contact **Kind**: global class -* [Wechaty](/zh/docs/api/wechaty.md#Wechaty) - * [new Wechaty\(\[options\]\)](/zh/docs/api/wechaty.md#new_Wechaty_new) - * _instance_ - * [.on\(event, listener\)](/zh/docs/api/wechaty.md#Wechaty+on) ⇒ [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty) - * [.start\(\)](/zh/docs/api//zh/docs/api/wechaty.md#Wechaty+start) ⇒ `Promise ` - * [.stop\(\)](/zh/docs/api/wechaty.md#Wechaty+stop) ⇒ `Promise ` - * [.logout\(\)](/zh/docs/api/wechaty.md#Wechaty+logout) ⇒ `Promise ` - * [.logonoff\(\)](/zh/docs/api/wechaty.md#Wechaty+logonoff) ⇒ `boolean` - * [.userSelf\(\)](/zh/docs/api/wechaty.md#Wechaty+userSelf) ⇒ `ContactSelf` - * [.say\(textOrContactOrFileOrUrl\)](/zh/docs/api/wechaty.md#Wechaty+say) ⇒ `Promise ` +* Wechaty + * new Wechaty\(\[options\]\) + * _实例_ + * .on\(event, listener\) ⇒ `Wechaty` + * .start\(\) ⇒ `Promise ` + * .stop\(\) ⇒ `Promise ` + * .logout\(\) ⇒ `Promise ` + * .logonoff\(\) ⇒ `boolean` + * .userSelf\(\) ⇒ `ContactSelf` + * .say\(textOrContactOrFileOrUrl\) ⇒ `Promise ` * _static_ - * [.instance\(\[options\]\)](/zh/docs/api/current/api/wechaty.md#Wechaty.instance) + * .instance\(\[options\]\) ### new Wechaty\(\[options\]\) @@ -42,7 +40,7 @@ title: Wechaty | Param | Type | Default | | :--- | :--- | :--- | -| \[options\] | [`WechatyOptions`](/zh/docs/api/api/wechaty.md#WechatyOptions) | `{}` | +| \[options\] | `WechatyOptions` | `{}` | **Example** _\(世界上最短的对话机器人代码\)_ @@ -55,7 +53,7 @@ bot.on('message', message => console.log(`Message: ${message}`)) bot.start() ``` -### wechaty.on\(event, listener\) ⇒ [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty) +### wechaty.on\(event, listener\) ⇒ `Wechaty` 当机器人收到消息,会触发一个事件,一些简单的事件介绍如下: @@ -64,15 +62,15 @@ bot.start() * **logout**: 当机器人退出登陆的时候,会触发到这个事件。 * **message**: 当有新消息的时候会触发这个事件。 -更多在 [WechatyEventName](/zh/docs/api/wechaty.md#WechatyEventName) +更多在 WechatyEventName -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 -**Returns**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty) +**Kind**: `Wechaty`的实例方法 +**Returns**: `Wechaty` | Param | Type | Description | | :--- | :--- | :--- | -| event | [`WechatyEventName`](/zh/docs/api/api/wechaty.md#WechatyEventName) | Emit WechatyEvent | -| listener | [`WechatyEventFunction`](/zh/docs/api/wechaty.md#WechatyEventFunction) | Depends on the WechatyEvent | +| event | `WechatyEventName` | Emit WechatyEvent | +| listener | `WechatyEventFunction` | Depends on the WechatyEvent | **示例** _\(Event:scan\)_ @@ -176,7 +174,7 @@ bot.on('error', (error) => { 启动机器人 > 备注:机器人所有的操作必须在这个函数执行完成之后。 -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 +**Kind**: `Wechaty`的实例方法 #### 示例 @@ -188,7 +186,7 @@ await bot.start() 停止机器人 -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 +**Kind**: `Wechaty`的实例方法 #### 示例 @@ -200,7 +198,7 @@ await bot.stop() 退出机器人 -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 +**Kind**: `Wechaty`的实例方法 #### 示例 @@ -212,7 +210,7 @@ await bot.logout() 获取机器人logon/logoff 的状态 -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 +**Kind**: `Wechaty`的实例方法 #### 示例 @@ -228,7 +226,7 @@ if (bot.logonoff()) { 获取当前机器人的所有信息 -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 +**Kind**: `Wechaty`的实例方法 #### 示例 @@ -243,7 +241,7 @@ console.log(`Bot is ${contact.name()}`) > 备注: 这个方法是否能实现,取决于用的是什么Puppet, 参照 [puppet-compatible-table](https://wechaty.js.org/docs/specs/puppet/) -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的实例方法 +**Kind**: `Wechaty`的实例方法 | Param | Type | Description | | :--- | :--- | :--- | @@ -287,11 +285,11 @@ await bot.say(linkPayload) 获取Wechaty的全局实例。 -**Kind**: [`Wechaty`](/zh/docs/api/wechaty.md#Wechaty)的静态方法 +**Kind**: `Wechaty`的静态方法 | Param | Type | Default | | :--- | :--- | :--- | -| \[options\] | [`WechatyOptions`](/zh/docs/api/wechaty.md#WechatyOptions) | `{}` | +| \[options\] | `WechatyOptions` | `{}` | #### 示例 From 7262d23b3efc0269bd776f09c44986f89f684e49 Mon Sep 17 00:00:00 2001 From: Annie Hermann Date: Sat, 9 Mar 2024 22:53:40 +0800 Subject: [PATCH 19/19] 0.11.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f885fd7a82..223b00fa9f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-docusaurus", - "version": "0.11.10", + "version": "0.11.11", "description": "Wechaty Official Website for Documentations", "private": true, "type": "module",