diff --git a/examples/professional/send-link.ts b/examples/professional/send-link.ts new file mode 100644 index 0000000..305fd3f --- /dev/null +++ b/examples/professional/send-link.ts @@ -0,0 +1,41 @@ +import { + Wechaty, + Message, + UrlLink, +} from 'wechaty' + +import { PuppetPadchat } from 'wechaty-puppet-padchat' + +import { generate } from 'qrcode-terminal' + + +const puppet = new PuppetPadchat() + +export const wechatyBot = Wechaty.instance({ + puppet, +}) + +wechatyBot + .on('scan', async (qrcode) => { + generate(qrcode, {small: true}) + + }) + .on('login', async function (user) { + console.log(user) + }) + .on('error', async err => { + console.error('BOT ERROR:', `exit for ${JSON.stringify(err.message || '')}`) + }) + .on('message', async function (m: Message) { + if (m.text() === 'ding') { + 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/chatie/wechaty', + }) + m.say(urlLink) + } + }) + +wechatyBot.start() diff --git a/package.json b/package.json index 9558d86..e57309a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-getting-started", - "version": "0.1.17", + "version": "0.1.19", "description": "Wechaty is a Wechat Bot SDK for Personal Account in Node.js", "main": "index.js", "engines": { @@ -27,7 +27,7 @@ "homepage": "https://github.com/Chatie/wechaty-getting-started#readme", "dependencies": { "qrcode-terminal": "^0.12.0", - "wechaty": "^0.28.1" + "wechaty": "^0.28.3" }, "devDependencies": { "@chatie/eslint-config": "^0.6.17",