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.
Requirements
- Your system must have Node.js installed (version >= 12).
- Your system must have Wechaty (version >= 0.40).
- Run wechaty-puppet-padlocal.
Deployment
Run wechaty-puppet-padlocal
:
- Linux
- macOS
- Windows
npm install wechaty-puppet-padlocal
export WECHATY_PUPPET=wechaty-puppet-padlocal
export WECHATY_PUPPET_PADLOCAL_TOKEN=__TOKEN__
npm start
npm install wechaty-puppet-padlocal
export WECHATY_PUPPET=wechaty-puppet-padlocal
export WECHATY_PUPPET_PADLOCAL_TOKEN=__TOKEN__
npm start
npm install wechaty-puppet-padlocal
set WECHATY_PUPPET=wechaty-puppet-padlocal
set 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
- Official Wechaty package: package/wechaty.
- Your free trail token for 7 days: pad-local.com.
You can follow up the steps mentioned below:
- 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
- Install Wechaty using the following commands:
npm install wechaty@latest
- Install PadLocal puppet using the following commands:
npm install wechaty-puppet-padlocal@latest
- Create a new folder
src
and add a filemy-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
*/
- 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
- Find out some more information about puppet from docs/puppet-providers.
- Find out the more bot repository from wechaty-getting-started.
- Find out the PadLocal repository at wechaty-puppet-padlocal.
- Find out API usage documentation at API usage documentation (TypeScript JavaScript).
- Find out common questions at Frequently Asked Questions List.