Skip to main content

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-padlocalexport WECHATY_PUPPET=wechaty-puppet-padlocalexport 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-botcd my-botnpm init -ynpm install ts-node typescript -g --registry=https://r.npm.taobao.orgtsc --init --target ES6
  1. Install Wechaty using the following commands:
npm install wechaty@latest --registry=https://r.npm.taobao.org
  1. Install PadLocal puppet using the following commands:
npm install wechaty-puppet-padlocal@latest --registry=https://r.npm.taobao.org
  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 tokenconst 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#