-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute.js
35 lines (34 loc) · 983 Bytes
/
route.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*!
* keydiarywx - route.js
* Copyright(c) 2013 Taobao.com
* Author: dead_horse <[email protected]>
*/
/**
* Module dependencies.
*/
//var urlrouter = require('urlrouter');
var wechat = require('wechat');
var config = require('./config');
var diary = require('./controller/diary');
var prompt = require('./controller/prompt');
module.exports = function (app) {
app.use('/weixin', wechat(config.token, function (req, res) {
if (req.weixin.MsgType !== 'text') {
return prompt.help(req, res);
}
var content = req.weixin.Content || '';
if (content.indexOf('@help') === 0 || content.indexOf('@帮助') === 0) {
return prompt.help(req, res);
}
if (content.indexOf('@+') === 0) {
return diary.append(req, res);
}
if (content.indexOf('@1') === 0) {
return diary.findToday(req, res);
}
if (content.indexOf('@提醒') === 0) {
return prompt.handleBind(req, res);
}
return diary.create(req, res);
}));
};