提交 37647305 编写于 作者: L linyimin 提交者: Huan (李卓桓)

add example code (#1757)

* add example code

* Make the piece of code in the bracket
上级 50565904
......@@ -343,10 +343,10 @@ export class Contact extends Accessory implements Sayable {
* // 4. send url link to contact
*
* const urlLink = new UrlLink ({
* description: 'this is url link description',
* thumbnailUrl: 'this is a thumbnail url',
* title: 'this is url link title',
* url: 'this is the url',
* 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/chatie/wechaty',
* })
* await contact.say(urlLink)
*/
......
......@@ -431,7 +431,7 @@ export class Message extends Accessory implements Sayable {
* This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/Chatie/wechaty/wiki/Puppet#3-puppet-compatible-table)
*
* @see {@link https://github.com/Chatie/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/ding-dong-bot.ts|Examples/ding-dong-bot}
* @param {(string | Contact | FileBox)} textOrContactOrFile
* @param {(string | Contact | FileBox | UrlLink)} textOrContactOrFile
* send text, Contact, or file to bot. </br>
* You can use {@link https://www.npmjs.com/package/file-box|FileBox} to send file
* @param {(Contact|Contact[])} [mention]
......@@ -468,6 +468,17 @@ export class Message extends Accessory implements Sayable {
* await msg.say(contactCard)
* }
*
* // 4. send Link
*
* if (/^link$/i.test(m.text())) {
* 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/chatie/wechaty',
* })
* await msg.say(linkPayload)
* }
* })
* .start()
*/
......
......@@ -985,7 +985,7 @@ export class Wechaty extends Accessory implements Sayable {
* > Tips:
* This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/Chatie/wechaty/wiki/Puppet#3-puppet-compatible-table)
*
* @param {(string | Contact | FileBox)} textOrContactOrFileOrUrl
* @param {(string | Contact | FileBox | UrlLink)} textOrContactOrFileOrUrl
* send text, Contact, or file to bot. </br>
* You can use {@link https://www.npmjs.com/package/file-box|FileBox} to send file
*
......@@ -1012,6 +1012,15 @@ export class Wechaty extends Accessory implements Sayable {
* import { FileBox } from 'file-box'
* const fileBox = FileBox.fromFile('/tmp/text.jpg')
* await bot.say(fileBox)
*
* // 5. send Link to bot itself
* 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/chatie/wechaty',
* })
* await bot.say(linkPayload)
*/
public async say (textOrContactOrFileOrUrl: string | Contact | FileBox | UrlLink): Promise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册