You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies



Abstract Puppet for Wechaty

Version published
Weekly downloads
decreased by-16.29%
Install size
36.5 MB
Weekly downloads




Powered by Wechaty NPM Version npm (tag) TypeScript Linux/Mac Build Status ES Modules

chatie puppet

Picture Credit:

Abstract(Base) Class of Puppet Providers for Wechaty Framework.

This module is part of the Wechaty Framework SDK.

Learn more at:

  1. Wiki:
  2. Issue:


Wechaty Puppet Provider Interface Documentation can be found at

Automatica Generated by TypeDoc



The above puppet provider is just for mocking and easy to understand. It will be a good starter when you want to develope a new puppet by yourself for fullfil your need, for example, connect Wechaty with Wechat Official Account.



  1. FileBox (npm module file-box) MUST be imported from wechaty-puppet because all the Wechaty Framework needs to check instanceof FileBox, we must be sure all FileBox is the same version.
  2. MemoryCard (npm module memory-card) MUST be imported from wechaty-puppet because all the Wechaty Framework needs to check instanceof MemoryCard, we must be sure all MemoryCard is the same version.

Peer Dependence

Puppet(npm module wechaty-puppet) itself must be a peer Dependencies for all the Puppet Providers, and should only be installed via Wechaty because all Puppet Providers should share the same Puppet Base Class with Wechaty, we must be sure all Puppet is the same version.

Wechaty Puppet Toolsets

1. Using SwitchState

You can get to know the puppet start/stop state from the state property:

  1. puppet.state.on() === 'pending' will be true when the puppet is starting
  2. puppet.state.on() === true will be true when the puppet is started
  3. === 'pending' will be true when the puppet is stoping
  4. ` === true' will be true when the puppet is stopped

Learn more about the puppet.state at

2. Using Brolog

Using Brolog to output necessary log messages.

2.1 Get log from Brolog
import { log } from 'brolog'
2.2 Log Format
log.verbose('ModuleName', 'methodName() Your Verbose Message Here')
log.silly('ModuleName', 'methodName() Your Silly Message Here')
2.3 Log Level

Brolog has five log levels, it should be used and follow the following rules:

Log LevelWhat does it meansUsage in Puppet
log.silly()There's some detail debug informationCan be used in everywhere as you like
log.verbose()There's some debug informationShould be used at the beginning of every method()'s something we need to let user knowShould NEVER to be used because Puppet is Library
log.warn()There's a Coverable ErrorShould not be used unless we have to
log.error()There's a Un-covered ErrorShould not be used unless we have to

3. Using LRU Cache

Set the max size for wechaty entities in LRU Cache.

Env NameWhat does it means
WECHATY_PUPPET_LRU_CACHE_SIZE_CONTACTThe max cache size for contact, default value 3000
WECHATY_PUPPET_LRU_CACHE_SIZE_FRIENDSHIPThe max cache size for friendship, default value 100
WECHATY_PUPPET_LRU_CACHE_SIZE_MESSAGEThe max cache size for message, default value 500
WECHATY_PUPPET_LRU_CACHE_SIZE_ROOMThe max cache size for room, default value 500
WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM_INVITATIONThe max cache size for room invitation, default value 100
WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM_MEMBERThe max cache size for room member, default value 30000


Pure Function



master v1.0 - Initial Release

v0.49 (Oct 2021)

  1. Add Error interface to EventErrorPayload, and make .data optional
  2. Using Mixin to extend Puppet

v0.43 (Aug 28, 2021)

  1. Support ES Modules

v0.16 (Sep 2019)

Works with the following Puppet Providers:

  1. wechaty-puppet-puppeteer
  2. wechaty-puppet-padchat
  3. wechaty-puppet-mock
  4. wechaty-puppet-wechat4u

v0.0.1 (Jun 2018)

  1. Define the Abstract Puppet Layer for Wechaty
  2. Seperate code from Wechaty


Huan LI (李卓桓)

Profile of Huan LI (李卓桓) on StackOverflow

  • Code & Docs © 2018-now Huan LI <>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons



Package last updated on 08 Jun 2022

Did you know?


Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog


Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc