0.4.16 • Published 3 years ago

ha-wechaty v0.4.16

Weekly downloads
8
License
Apache-2.0
Repository
github
Last release
3 years ago

HAWechaty

NPM Version NPM

HAWechaty

HAWechaty is a Load Balance for providing High Availability for Wechaty Chatbot by spreading requests across multiple WeChat individual accounts.

Powered by Wechaty

One two three, chatbots team up!

The Problem

Currently we have only one bot on WeChat, which means that if the bot was offline, then our service will be stopped.

The Solution

Use two (3 or even 4 will be better) WeChat bot at the same time, with the different wechaty-puppet providers (for example: padplus + windows).

So when an issue event has come, we can use a RR (round robin) or other very easy to implementing algorithm to make our service both load-balancable and high-available.

Usage

import {
  HAWechaty,
}                   from 'ha-wechaty'
import {
  WechatyOptions,
}                   from 'wechaty'

const hostieWechatyOptions: WechatyOptions = {
  puppet: 'wechaty-puppet-hostie',
  puppetOptions: {
    token: 'hostie-token'
  }
}

const padplusWechatyOptions: WechatyOptions = {
  puppet: 'wechaty-puppet-padplus',
  puppetOptions: {
    token: 'padplus-token'
  }
}

const haWechaty = new HAWechaty({
  name: 'high-available-wechaty',
  wechatyOptionsList: [
    hostieWechathyOptions,
    padplusWechatyOptions,
  ]
})

haWechaty.start()

Environment Variables

1 HA_WECHATY_PUPPET

The wechaty puppet list, seprated by a colon (:).

Examples:

export HA_WECHATY_PUPPET=wechaty-puppet-hostie:wechaty-puppet-padplus

2 HA_WECHATY_PUPPET_${PROTOCOL}_TOKEN

The ${PROTOCOL} could be the puppet name that the Wechaty supported.

For example:

Puppet Provider${PROTOCOL}HAWECHATY_PUPPET${PROTOCOL}_TOKEN
wechaty-puppet-hostiehostieHA_WECHATY_PUPPET_HOSTIE_TOKEN
wechaty-puppet-padpluspadplusHA_WECHATY_PUPPET_PADPLUS_TOKEN
wechaty-puppet-macpromacproHA_WECHATY_PUPPET_MACPRO_TOKEN

The token set to this environment variable will become the default value of puppetOptions.token when instanciating Wechaty.

To specify more tokens for a specific puppet, use a colon (:) to seprate them, for example:

export HA_WECHATY_PUPPET_HOSTIE_TOKEN=hostie_token_1:hostie_token_2

History

master

v0.0.1 (Apr 2020)

This module was originally design for the project OSSChat #58

  1. Publish the NPM module ha-wechaty

Links

  1. RxJS recipes: ‘forkJoin’ with the progress of completion for bulk network requests in Angular
  2. Handle multiple API requests in Angular using mergeMap and forkJoin to avoid nested subscriptions
  3. Googl Cloud - Truncated exponential backoff
  4. Power of RxJS when using exponential backoff

Author

Huan LI (李卓桓) zixia@zixia.net

Profile of Huan LI (李卓桓) on StackOverflow

Copyright & License

  • Code & Docs © 2020-now Huan LI \zixia@zixia.net\
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons
0.9.12

3 years ago

0.9.8

3 years ago

0.9.9

3 years ago

0.9.10

3 years ago

0.9.6

3 years ago

0.9.11

3 years ago

0.9.5

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.7.7

3 years ago

0.7.6

3 years ago

0.7.5

3 years ago

0.7.2

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.5.1

3 years ago

0.4.15

3 years ago

0.4.16

3 years ago

0.4.13

3 years ago

0.4.12

4 years ago

0.4.10

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.11

4 years ago

0.4.1

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.1

4 years ago