GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - willin/tuling: 图灵机器人SDK for Node.js

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.eslintrc.js
.eslintrc.js
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
README.md
README.md
 
 
package.json
package.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

图灵机器人SDK

npm npm npm

安装

npm install --save tuling

使用

ES7:

const TULING = require('tuling');

const tuling = new TULING({key: 'xxx'});

(async() => {
  const result = await tuling.send({
    userid: 1,
    info: '你好吗',
    loc: '南京市'
  });
  console.log(result);
})();

ES5:

var TULING = require('tuling');

var tuling = new TULING({key: 'xxx'});

tuling.send({
  userid: 1,
  info: '你好吗',
  loc: '南京市'
}).then(function(result) {
  console.log(result);
})

进阶

微信语音识别接入简单示例:

var TULING = require('tuling');
var wechat = require('wechat');
var express = require('express');

// 填入配置项
var config = {
  token: 'xxxx',
  appid: 'xxxx',
  encodingAESKey: 'xxxx'
};
var tuling = new TULING({key: 'xxxx'});

var app = express();
app.use(express.query());

app.use('/', wechat(config, function (req, res, next) {
  var message = req.weixin;
  console.log(message);
  if(message.Event!==undefined && message.Event ==='subscribe'){
    return res.reply('欢迎关注xxxx,目前正处于测试阶段。');
  }
  if(message.MsgType==='text' || message.MsgType==='voice'){
    return tuling.send({
      userid: message.FromUserName,
      info: message.Content || message.Recognition
    }).then(function(result){
      switch (result.code) {
        case 200000:
          return res.reply('<a href="'+result.url+'">'+result.text+'</a>');
          break;
        case 302000:
          var html = result.text;
          for(item of result.list){
            if(item.article!==''){
              html+= ',<a href="'+item.detailurl+'">'+item.article+'</a>'
            }
          }

          return res.reply(html);
          break;
        case 308000:
            var html = result.text;
            for(item of result.list){
              html+=',<a href="'+item.detailurl+'">'+item.name+'</a>'
            }

            return res.reply(html);
            break;
        default:
         return res.reply(result.text);
      }
    });
  }
}));

app.listen(8080);

License

MIT

通过支付宝捐赠:

qr

About

图灵机器人SDK for Node.js

Topics

botsdktuling

Resources

Readme

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

8 stars

Watchers

3 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.