diff --git a/README.md b/README.md index c2df736..c622262 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,12 @@ this.body = [ } ]; ``` + +#### 回复空串 +```js +this.body = ''; +``` + #### 转发到客服接口 ```js this.body = { diff --git a/lib/wechat.js b/lib/wechat.js index c93c3b9..538dd2c 100644 --- a/lib/wechat.js +++ b/lib/wechat.js @@ -271,7 +271,16 @@ wechat.prototype.middleware = function (handle) { } } - replyMessageXml = reply(this.body, formated.ToUserName, formated.FromUserName); + /* + * 假如服务器无法保证在五秒内处理并回复,可以直接回复空串。 + * 微信服务器不会对此作任何处理,并且不会发起重试。 + */ + if (this.body === '') { + return; + } + + var replyMessageXml = reply(this.body, formated.ToUserName, formated.FromUserName); + if (!query.encrypt_type || query.encrypt_type === 'raw') { this.body = replyMessageXml; } else { diff --git a/package.json b/package.json index 6f84ab6..3553c71 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,10 @@ "scripts": { "test": "make test-all" }, + "repository": { + "type": "git", + "url": "https://github.com/node-webot/co-wechat" + }, "keywords": [ "wechat", "wexin"