Code Monkey home page Code Monkey logo

wechaty-puppet's Introduction

WECHATY PUPPET

Powered by Wechaty NPM Version npm (tag) TypeScript Linux/Mac Build Status Greenkeeper badge

chatie puppet

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

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

This module is part of the Wechaty SDK.

Learn more at:

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

DOCUMENTATION

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

Automatica Generated by TypeDoc

EXAMPLE

PuppetMock: https://github.com/chatie/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

Peer Dependence

  1. FileBox (npm module file-box) must be a peerDependencies 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 a peerDependencies because all the Wechaty Framework needs to check instanceof MemoryCard, we must be sure all MemoryCard is the same version.
  3. 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.

CODING WITH PUPPET

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/zixia/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

Resources

Pure Function

AUTHOR

Huan LI <[email protected]>

profile for zixia on Stack Exchange, a network of free, community-driven Q&A sites

COPYRIGHT & LICENSE

  • Code & Docs © 2018 Huan LI <[email protected]>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

wechaty-puppet's People

Contributors

huan avatar greenkeeper[bot] avatar windmemory avatar zhaoic avatar gcaufy avatar su-chang avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.