mirror of
https://github.com/wechaty/getting-started.git
synced 2026-10-17 05:20:49 +08:00
Add send link demo (#88)
* add send link demo * 0.1.18 * remove unnecessary library * 0.1.19
This commit is contained in:
@@ -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
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user