Deploy in WeChat4U
WeChat4U is an excellent wechat bot framework that supports both Node.js and Browser, with rich features and an active community of experienced contributors. In this how to guide, you will learn how to deploy the bot in WeChat4U 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).
- You must be familiar with wechaty-puppet-wechat4u.
Deployment
Run wechaty-puppet-wechat4u
:
- Linux
- macOS
- Windows
npm install wechaty-puppet-wechat4u
export WECHATY_PUPPET=wechaty-puppet-wechat4u
npm start
npm install wechaty-puppet-wechat4u
export WECHATY_PUPPET=wechaty-puppet-wechat4u
npm start
npm install wechaty-puppet-wechat4u
set WECHATY_PUPPET=wechaty-puppet-wechat4u
npm start
Integration
Let's take up an example on how to integrate bot from starter templete to WeChat4U. The step is similar for all other bots as well.
Prerequisite
- Official Wechaty package: package/wechaty.
- QRCode terminal edition: package/qrcode-terminal.
You can follow up the steps mentioned below:
- Initialize the project by creating a new folder
my-bot
:
mkdir my-bot
cd my-bot
- Install the dependencies using the following commands:
npm install wechaty
npm install qrcode-terminal
- Install the puppet using the following commands:
npm install --save wechat4u@latest
npm install wechaty-puppet-wechat4u
- Create a new folder
src
and add a filemy-bot.js
. Add any of the functions from add functionality to the bot section to the snippet below:
import { Wechat } from 'wechat4u'
import {
Contact,
Message,
ScanStatus,
Wechaty,
log,
} from 'wechaty'
import { qrTerm } from 'qrcode-terminal'
console.log(welcome)
const bot = new Wechaty()
// or use the core API
// import { WechatCore } from 'wechat4u/lib/core'
/*
*Your function goes here
*/
- After you are done with the file, you can run the bot using the following commands:
export WECHATY_LOG=verbose
export WECHATY_PUPPET=wechaty-puppet-wechat4u
node src/my-bot.js
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 WeChat4U repository at wechaty-puppet-wechat4u.
- Find out it usage at PuppetWechat4u.
Blogs
To be Added