Git Product home page Git Product logo

n-robot's Introduction

Node.js 微信机器人

调用的 simsimi 的接口进行消息回复,可以去官网注册并申请 7 天免费的 Trial-key 。

注意: 1. 只接收微信的文字消息 2.把 key 替换成自己申请的 key 3.回复规则里植入广告太多,大家注意甄别 = =

var http = require('http'),
    wechat = require('node-wechat'),
    request = require('request');

http.createServer(function (req, res) {
  wechat.handler(req, res);
  wechat.text(function (data) {
    var simsimi = {
      key: "your simsimi's key",
      lc: "ch",
      ft: "0.0",
      text : data.Content
    }
    var msg = {
      FromUserName : data.ToUserName,
      ToUserName : data.FromUserName,
      MsgType : "text",
      Content : "",
      FuncFlag : 0
    }
    var url = "http://sandbox.api.simsimi.com/request.p?key=" + simsimi.key + "&lc=" + simsimi.lc + "&ft=" + simsimi.ft + "&text=" + simsimi.text;
    request(url, function (err, res, body) {
      if (!err && res.statusCode == 200) {
        body = JSON.parse(body);
        msg.Content = body.response;
        wechat.send(msg);
      }
    });
  });
}).listen(80);

n-robot's People

Contributors

nswbmw avatar

Watchers

 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.