Skip to content

mcgrimm/N-robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

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 = "https://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);

About

Node.js 微信机器人

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published