Giter Site home page Giter Site logo

wechaty-puppet-padlocal's Introduction

PUPPET-PADLOCAL

NPM Version Powered by Wechaty Powered by padlocal-client-ts TypeScript Stage

NOTICE: our dev machines are all Macs, may not adapt other platforms perfectly at the moment. If you have any problems during using this puppet, issues are welcome to open.

HOW TO USE

Play with Wechaty

PadLocal is a complete Wechaty puppet implementation. You can use all the Wechaty apis as always. ๐Ÿ‘‰๐Ÿป https://github.com/wechaty/wechaty#guitar-api

All you need to do is to provide PadLocal as Wechaty puppet:

const bot = new Wechaty({
    name: "PadLocalBot",
    new PuppetPadlocal({
    	endpoint: `${padLocalHost}:${padLocalPort}`,
    	token: padLocalToken,
    	serverCAFilePath: padLocalServerCAFilePath
    })
})

wechaty-puppet-padlocal-demo

Also, we provided a simple demo project to show how to use padlocal puppet. You can checkout this repo to see how it works.

If you want to explore PadLocal step by step, following instructions may be helpful.

Step by step instructions

1. Check your Node version first, >= v12

node --version // >= v12.0.0

2. Create and init your bot project

mkdir my-padlocal-bot && cd my-padlocal-bot
npm init -y
npm install ts-node typescript -g --registry=https://r.npm.taobao.org
tsc --init --target ES6

3. Install Wechaty and Padlocal puppet

npm install wechaty@latest --registry=https://r.npm.taobao.org
npm install wechaty-puppet-padlocal@latest --registry=https://r.npm.taobao.org

4. Write bot demo code

// bot.ts

import {PuppetPadlocal} from "wechaty-puppet-padlocal";
import {Contact, Message, ScanStatus, Wechaty} from "wechaty";

const host: string = ""             // padlocal server host
const port: number = 0              // padlocal server port
const token: string = ""            // padlocal token
const serverCAFilePath: string = "" // padlocal server ca file path

const puppet = new PuppetPadlocal({
  endpoint: `${host}:${port}`,
  token,
  serverCAFilePath
})

const bot = new Wechaty({
    name: "TestBot",
    puppet,
})

bot
.on("scan", (qrcode: string, status: ScanStatus) => {
    if (status === ScanStatus.Waiting && qrcode) {
        const qrcodeImageUrl = ["https://api.qrserver.com/v1/create-qr-code/?data=", encodeURIComponent(qrcode)].join("");
        console.log(`onScan: ${ScanStatus[status]}(${status}) - ${qrcodeImageUrl}`);
    } else {
        console.log(`onScan: ${ScanStatus[status]}(${status})`);
    }
})

.on("login", (user: Contact) => {
    console.log(`${user} login`);
})

.on("logout", (user: Contact) => {
    console.log(`${user} logout`);
})

.on("message", async (message: Message) => {
    console.log(`on message: ${message.toString()}`);
})

.start()

console.log("TestBot", "started");
ts-node bot.ts

PUPPET COMPARISON

ๅŠŸ่ƒฝ padpro padplus macpro padlocal
<ๆถˆๆฏ>
ๆ”ถๅ‘ๆ–‡ๆœฌ โœ… โœ… โœ… โœ…
ๆ”ถๅ‘ไธชไบบๅ็‰‡ โœ… โœ… โœ… โœ…
ๆ”ถๅ‘ๅ›พๆ–‡้“พๆŽฅ โœ… โœ… โœ… โœ…
ๅ‘้€ๅ›พ็‰‡ใ€ๆ–‡ไปถ โœ… โœ…๏ผˆๅฏนๅ†…ๅฎนๆœ‰ๅคงๅฐ้™ๅˆถ๏ผŒ20Mไปฅไธ‹๏ผ‰ โœ… โœ…
ๆŽฅๆ”ถๅ›พ็‰‡ใ€ๆ–‡ไปถ โœ… โœ…๏ผˆๅฏนๅ†…ๅฎนๆœ‰ๅคงๅฐ้™ๅˆถ๏ผŒ25Mไปฅไธ‹๏ผ‰ โœ… โœ…
ๅ‘้€่ง†้ข‘ โœ… โœ… โœ… โœ…
ๆŽฅๆ”ถ่ง†้ข‘ โœ… โœ… โœ… โœ…
ๅ‘้€ๅฐ็จ‹ๅบ โŒ โœ… โœ… โœ…
ๆŽฅๆ”ถๅŠจๅ›พ โŒ โœ… โœ… โœ…
ๅ‘้€ๅŠจๅ›พ โŒ โœ… โœ… โœ…
ๆŽฅๆ”ถ่ฏญ้Ÿณๆถˆๆฏ โœ… โœ… โœ… โœ…
ๅ‘้€่ฏญ้Ÿณๆถˆๆฏ โœ… โŒ โŒ โœ…
่ฝฌๅ‘ๆ–‡ๆœฌ โœ… โœ… โœ… โœ…
่ฝฌๅ‘ๅ›พ็‰‡ โœ… โœ… โœ… โœ…
่ฝฌๅ‘ๅ›พๆ–‡้“พๆŽฅ โœ… โœ… โœ… โœ…
่ฝฌๅ‘้Ÿณ้ข‘ โœ… โŒ โœ… โœ…
่ฝฌๅ‘่ง†้ข‘ โœ… โœ… โœ… โœ…
่ฝฌๅ‘ๆ–‡ไปถ โœ… โœ… โœ… โœ…
่ฝฌๅ‘ๅŠจๅ›พ โŒ โŒ โŒ โŒ
่ฝฌๅ‘ๅฐ็จ‹ๅบ โŒ โœ… โŒ โœ…
<็พค็ป„>
ๅˆ›ๅปบ็พค่Š โœ… โœ… โœ… โœ…
่ฎพ็ฝฎ็พคๅ…ฌๅ‘Š โœ… โœ… โœ… โœ…
่Žทๅ–็พคๅ…ฌๅ‘Š โŒ โœ… โŒ โœ…
็พคไบŒ็ปด็  โœ… โœ… โœ… โœ…
ๆ‹‰ไบบ่ฟ›็พค โœ… โœ… โœ… โœ…
่ธขไบบๅ‡บ็พค โœ… โœ… โœ… โœ…
้€€ๅ‡บ็พค่Š โœ… โœ… โœ… โœ…
ๆ”น็พคๅ็งฐ โœ… โœ… โœ… โœ…
ๅ…ฅ็พคไบ‹ไปถ โœ… โœ… โœ… โœ…
็ฆป็พคไบ‹ไปถ โœ… โœ… โœ… โœ…
็พคๅ็งฐๅ˜ๆ›ดไบ‹ไปถ โœ… โœ… โœ… โœ…
@็พคๆˆๅ‘˜ โœ… โœ… โœ… โœ…
็พคๅˆ—่กจ โœ… โœ… โœ… โœ…
็พคๆˆๅ‘˜ๅˆ—่กจ โœ… โœ… โœ… โœ…
็พค่ฏฆๆƒ… โœ… โœ… โœ… โœ…
<่”็ณปไบบ>
ไฟฎๆ”นๅค‡ๆณจ โœ… โœ… โœ… โœ…
ๆทปๅŠ ๅฅฝๅ‹ โœ… โœ… โœ… โœ…
่‡ชๅŠจ้€š่ฟ‡ๅฅฝๅ‹ โœ… โœ… โŒ โœ…
ๆทปๅŠ ๅฅฝๅ‹ โœ… โœ… โœ… โœ…
ๅฅฝๅ‹ๅˆ—่กจ โœ… โœ… โœ… โœ…
ๅฅฝๅ‹่ฏฆๆƒ… โœ… โœ… โœ… โœ…
<ๅ…ถไป–>
็™ปๅฝ•ๅพฎไฟก โœ… โœ… โœ… โœ…
ๆ‰ซ็ ็Šถๆ€ โœ… โœ… โŒ โœ…
้€€ๅ‡บๅพฎไฟก โœ… โœ… โœ… โœ…
ไพ่ต–ๅ่ฎฎ iPad iPad Mac iPad

HOW TO GET TOKEN

Padlocal is in beta testing stage, granting tokens to limited partners. If you want to apply, please contact admin for further information.

wechaty-puppet-padlocal's People

Contributors

padlocal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.