Code Monkey home page Code Monkey logo

wechatcheckin's Introduction

Introduction

This is a wechat project. It is for user to mark this tasks every day. When user finishes his/her task, he/she marks on wechat and then wechat will notify other users that the user is finished his/her task.

If someone doesn't finished his/her task, they can do some punishment offline. Later on, more functions will be added.

Using this Repository

  • Install Node.js
  • Install Redis or find a redis to use
  • Install ngrok if you don't have a public server. ngrok will help proxy wechat message to your server.

How to use this Repository

  1. Edit your config information in env_git file.
    Set your wechat account information and redis information in env_git file.

  2. Install packages.

    npm install
    
  3. Add users you want to notify when "ๆ‰“ๅก" is clicked.
    This step should be automatically set, but now I haven't added this function. For test, you can set users information by running the test in lib/test/msg-machine/UserManagerTest.js, but you should change the user id to yours first.

    //you can also set mocha to global	
    node_modules/mocha/bin/mocha lib/test/msg-machine/UserManagerTest.js
    
  4. Run the server.

    source env_git; node app.js
    
  5. Test server.

    //change FromUserName field in menu.xml to your own user id.	cd moch_client
    node send.js menu.xml
    

Connect to WeChat Account

If you have a public server, config YOUR_PUBLIC_SERVER/msg to receive WeChat message, otherwise using the following method.

  1. ngrok to proxy messages.

    // proxy your server port
    $>ngrok http 3456
    ngrok by @inconshreveable                                             (Ctrl+C to quit)                                                                              
    Tunnel Status                 online                                                  
    Update                        update available (version 2.1.14, Ctrl-U to update)     
    Version                       2.1.3                                                   
    Region                        United States (us)                                      
    Web Interface                 http://127.0.0.1:4040                                   
    Forwarding                    http://6e0771c0.ngrok.io -> localhost:3456              
    Forwarding                    https://6e0771c0.ngrok.io -> localhost:3456             
                                                                                      
    Connections                   ttl     opn     rt1     rt5     p50     p90             
                              171     0       0.00    0.00    0.40    0.42  
    

    After you run the command, it will show the public address to forward message, the following example is http://6e0771c0.ngrok.io, so config receive message url to http://6e0771c0.ngrok.io/msg.

  2. Start server

    source env_git; node app.js
    

Technical Learning

  1. Redis
    Redis is a fast cache. Here we use SortedSet to filter duplicated message, HashSet to store user information.
  2. Token
    We use token to access WeChat API, how about manage the token distributely. Here we also use redis to store the token value.

WeChat API

WeChat API can be found here

wechatcheckin's People

Watchers

James Cloos avatar chaotang0281 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.