wechaty-puppet
TypeScript icon, indicating that this package has built-in type declarations

1.20.2 • Public • Published

wechaty-puppet

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

chatie puppet

Picture Credit: https://www.shareicon.net

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

This module is part of the Wechaty Framework SDK.

Learn more at:

  1. Wiki: https://github.com/wechaty/wechaty/wiki/Puppet
  2. Issue: https://github.com/wechaty/wechaty/issues/1167

Documentation

Wechaty Puppet Provider Interface Documentation can be found at https://wechaty.github.io/wechaty-puppet/typedoc/classes/puppet.html

Automatica Generated by TypeDoc

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

  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. puppet.state.off() === 'pending' will be true when the puppet is stoping
  4. `puppet.state.off() === true' will be true when the puppet is stopped

Learn 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

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 Level What does it means Usage in Puppet
log.silly() There's some detail debug information Can be used in everywhere as you like
log.verbose() There's some debug information Should be used at the beginning of every method()
log.info() There's something we need to let user know Should NEVER to be used because Puppet is Library
log.warn() There's a Coverable Error Should not be used unless we have to
log.error() There's a Un-covered Error Should not be used unless we have to

3. Using LRU Cache

Set the max size for wechaty entities in LRU Cache.

Env Name What does it means
WECHATY_PUPPET_LRU_CACHE_SIZE_CONTACT The max cache size for contact, default value 3000
WECHATY_PUPPET_LRU_CACHE_SIZE_FRIENDSHIP The max cache size for friendship, default value 100
WECHATY_PUPPET_LRU_CACHE_SIZE_MESSAGE The max cache size for message, default value 500
WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM The max cache size for room, default value 500
WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM_INVITATION The max cache size for room invitation, default value 100
WECHATY_PUPPET_LRU_CACHE_SIZE_ROOM_MEMBER The max cache size for room member, default value 30000

Resources

Pure Function

Mixin

History

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

Author

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

Profile of Huan LI (李卓桓) on StackOverflow

Copyright & License

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.20.2655latest
1.21.319next

Version History

VersionDownloads (Last 7 Days)Published
1.21.319
1.21.20
1.21.10
1.20.2655
1.20.14
1.19.70
1.19.60
1.19.50
1.19.40
1.19.30
1.19.10
1.18.30
1.18.20
1.18.10
1.18.00
1.17.10
1.15.10
1.13.150
1.13.140
1.13.130
1.13.120
1.13.110
1.13.100
1.13.90
1.13.80
1.13.70
1.13.60
1.13.50
1.11.170
1.11.160
1.11.152
1.11.140
1.11.120
1.11.110
1.11.100
1.11.90
1.11.80
1.11.70
1.11.60
1.11.30
1.11.20
1.10.24
1.10.10
1.7.253
1.7.240
1.7.230
1.7.220
1.7.210
1.7.200
1.7.190
1.7.180
1.7.170
1.7.160
1.7.150
1.7.140
1.7.130
1.7.120
1.7.100
1.7.90
1.7.80
1.7.70
1.7.60
1.7.50
1.7.20
1.5.70
1.5.60
1.5.50
1.5.40
1.5.30
1.3.80
1.3.70
1.3.60
1.3.50
1.3.40
1.3.30
1.3.20
1.2.110
1.2.100
1.2.90
1.2.80
1.2.70
1.2.60
1.2.50
1.2.40
1.2.30
1.2.21
1.2.10
1.0.20
1.0.10
0.53.100
0.53.90
0.53.80
0.53.70
0.53.60
0.53.50
0.53.40
0.53.20
0.53.30
0.53.10
0.52.10
0.51.213
0.51.200
0.51.180
0.51.170
0.51.160
0.51.150
0.51.140
0.51.100
0.51.70
0.51.60
0.51.50
0.51.40
0.51.30
0.51.20
0.51.10
0.49.230
0.49.220
0.49.210
0.49.200
0.49.190
0.49.180
0.49.130
0.49.120
0.49.100
0.49.90
0.49.80
0.49.70
0.49.30
0.47.84
0.47.70
0.47.60
0.47.40
0.47.50
0.47.30
0.47.20
0.47.10
0.45.94
0.45.40
0.45.30
0.45.20
0.43.130
0.43.120
0.43.110
0.43.100
0.43.90
0.43.80
0.43.70
0.43.60
0.43.50
0.43.40
0.41.911
0.41.80
0.41.70
0.40.00
0.41.60
0.41.40
0.41.30
0.41.20
0.41.10
0.39.20
0.39.10
0.37.20
0.37.10
0.35.35
0.35.10
0.34.30
0.34.20
0.34.10
0.33.91
0.33.80
0.33.60
0.33.51
0.33.40
0.33.30
0.33.20
0.33.10
0.33.00
0.32.30
0.32.20
0.32.10
0.32.00
0.31.70
0.31.60
0.31.50
0.31.40
0.31.30
0.31.10
0.31.00
0.30.61
0.30.50
0.30.40
0.30.30
0.29.40
0.29.30
0.29.20
0.27.10
0.26.23
0.26.10
0.25.80
0.25.70
0.25.60
0.25.50
0.25.40
0.25.30
0.25.20
0.25.10
0.24.01
0.23.90
0.23.80
0.23.60
0.23.50
0.23.40
0.23.30
0.23.20
0.23.10
0.21.120
0.21.110
0.21.100
0.21.90
0.21.80
0.21.70
0.21.60
0.21.50
0.21.30
0.21.20
0.20.20
0.20.10
0.20.00
0.19.170
0.19.160
0.19.150
0.19.140
0.19.120
0.19.110
0.19.100
0.19.90
0.19.80
0.19.70
0.19.60
0.19.50
0.19.40
0.19.10
0.18.30
0.17.253
0.17.240
0.17.237
0.17.220
0.17.210
0.17.200
0.17.170
0.17.160
0.17.140
0.17.120
0.17.100
0.17.70
0.17.50
0.17.40
0.17.30
0.17.20
0.17.10
0.16.10
0.15.280
0.15.270
0.15.260
0.15.250
0.15.230
0.15.220
0.15.210
0.15.200
0.15.190
0.15.180
0.15.150
0.15.140
0.15.130
0.15.120
0.15.110
0.15.100
0.15.90
0.15.80
0.15.70
0.15.60
0.15.40
0.15.30
0.15.10
0.14.12
0.13.180
0.13.170
0.13.150
0.13.140
0.13.130
0.13.120
0.13.110
0.13.90
0.13.70
0.13.60
0.13.50
0.11.60
0.11.50
0.11.40
0.11.30
0.9.250
0.9.240
0.9.230
0.9.220
0.9.210
0.9.200
0.9.190
0.9.180
0.9.170
0.9.160
0.9.120
0.9.110
0.9.100
0.9.90
0.9.80
0.9.71
0.9.60
0.9.50
0.9.40
0.9.30
0.9.20
0.8.60
0.8.50
0.8.43
0.8.20
0.6.110
0.8.10
0.6.100
0.6.90
0.6.80
0.6.70
0.6.60
0.6.50
0.6.40
0.6.30
0.6.20
0.4.40
0.4.30
0.4.20
0.4.10
0.3.30
0.2.130
0.2.120
0.2.110
0.2.100
0.2.90
0.2.80
0.2.70
0.2.60
0.2.50
0.2.40
0.2.30
0.2.10
0.2.00
0.1.50
0.1.40
0.1.30
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.30

Package Sidebar

Install

npm i wechaty-puppet

Weekly Downloads

738

Version

1.20.2

License

Apache-2.0

Unpacked Size

1.35 MB

Total Files

738

Last publish

Collaborators

  • zixia