跳到主要内容

Deploy in PadLocal

PadLocal is a most powerful Wechaty puppet provider which consumes Wechaty puppet services and includes sending or receiving files, texts individually or in a group. In this how to guide, you will learn how to deploy the bot in PadLocal locally and integrate bot from the list of examples present in starter templete.

Deploy in PadLocal

Requirements

  1. Your system must have Node.js installed (version >= 12).
  2. Your system must have Wechaty (version >= 0.40).
  3. Run wechaty-puppet-padlocal.

Deployment

Run wechaty-puppet-padlocal:

npm install wechaty-puppet-padlocal
export WECHATY_PUPPET=wechaty-puppet-padlocal
export WECHATY_PUPPET_PADLOCAL_TOKEN=__TOKEN__
npm start

Integration

Let's take up an example on how to integrate bot from starter templete to PadLocal. The step is similar for all other bots as well.

Prerequisite

  1. Official Wechaty package: package/wechaty.
  2. Your free trail token for 7 days: pad-local.com.

You can follow up the steps mentioned below:

  1. Initialize the project by creating a new folder my-bot.
mkdir my-bot
cd my-bot
npm init -y
npm install ts-node typescript -g
tsc --init --target ES6
  1. Install Wechaty using the following commands:
npm install wechaty@latest
  1. Install PadLocal puppet using the following commands:
npm install wechaty-puppet-padlocal@latest
  1. Create a new folder src and add a file my-bot.ts. Add any of the functions from add functionality to the bot section to the snippet below:
import {PuppetPadlocal} from "wechaty-puppet-padlocal";
import {Contact, Message, ScanStatus, Wechaty} from "wechaty";

const token: string = "" // padlocal token
const puppet = new PuppetPadlocal({ token })
const bot = new Wechaty({
name: "TestBot",
puppet,
})
/*
*Your function goes here
*/
  1. After you are done with the file, you can run the bot using the following commands:
ts-node my-bot.ts

Now, you are ready to play with the bot!

You can deploy the bot with popular container solutions as well such as:

References

Blogs