Add send link demo (#88)

* add send link demo

* 0.1.18

* remove unnecessary library

* 0.1.19
This commit is contained in:
linyimin
2019-10-16 11:41:47 +08:00
committed by Huan (李卓桓)
parent c867acabfe
commit f6697da38d
2 changed files with 43 additions and 2 deletions
+41
View File
@@ -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()
+2 -2
View File
@@ -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",