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.
PuppetService gRPC Proxy via Chatie.io(PaaS - Puppets as a Service), created by @huan
Dependencies
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.
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:
puppet.state.on() === 'pending' will be true when the puppet is starting
puppet.state.on() === true will be true when the puppet is started
puppet.state.off() === 'pending' will be true when the puppet is stoping
`puppet.state.off() === true’ will be true when the puppet is stopped
wechaty-puppet
Abstract(Base) Class of Puppet Providers for Wechaty Framework.
This module is part of the Wechaty Framework SDK.
Learn more at:
Documentation
Wechaty Puppet Provider Interface Documentation can be found at https://wechaty.github.io/wechaty-puppet/typedoc/classes/puppet.html
Example
PuppetMock: https://github.com/wechaty/wechaty-puppet-mock
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.
Providers
Dependencies
FileBox(npm modulefile-box) MUST be imported fromwechaty-puppetbecause all the Wechaty Framework needs to checkinstanceof FileBox, we must be sure allFileBoxis the same version.MemoryCard(npm modulememory-card) MUST be imported fromwechaty-puppetbecause all the Wechaty Framework needs to checkinstanceof MemoryCard, we must be sure allMemoryCardis the same version.Peer Dependence
Puppet(npm modulewechaty-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 allPuppetis the same version.Wechaty Puppet Toolsets
1. Using SwitchState
You can get to know the puppet start/stop state from the
stateproperty:puppet.state.on() === 'pending'will be true when the puppet is startingpuppet.state.on() === truewill be true when the puppet is startedpuppet.state.off() === 'pending'will be true when the puppet is stopingLearn more about the puppet.state at https://github.com/huan/state-switch
2. Using Brolog
Using Brolog to output necessary log messages.
2.1 Get log from Brolog
2.2 Log Format
2.3 Log Level
Brolog has five log levels, it should be used and follow the following rules:
log.silly()log.verbose()log.info()There’s something we need to let user knowShould NEVER to be used because Puppet is Librarylog.warn()log.error()3. Using LRU Cache
Set the max size for wechaty entities in LRU Cache.
WECHATY_PUPPET_LRU_CACHE_SIZE_CONTACT3000WECHATY_PUPPET_LRU_CACHE_SIZE_FRIENDSHIP100WECHATY_PUPPET_LRU_CACHE_SIZE_MESSAGE500WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM500WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM_INVITATION100WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM_MEMBER30000Resources
Pure Function
Mixin
History
master v1.0 - Initial Release
v0.49 (Oct 2021)
AddErrorinterface toEventErrorPayload, and make.dataoptionalPuppetv0.43 (Aug 28, 2021)
v0.16 (Sep 2019)
Works with the following Puppet Providers:
v0.0.1 (Jun 2018)
Author
Huan LI (李卓桓) zixia@zixia.net
Copyright & License