Socket
Book a DemoInstallSign in
Socket

@neuroo_fe/wechat-reply

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neuroo_fe/wechat-reply

微信关键字自动回复模块

1.1.2
latest
Source
npmnpm
Version published
Maintainers
4
Created
Source

wechat-reply

微信关键字自动回复。

Usage

npm install @neuroo_fe/wechat-reply -S
const app = require('express')()
const wechat = require('wechat')
const Reply = require('@neuroo_fe/wechat-reply')
const options = {
  rules: [
    {
      keywords: ['包含', '^匹配开头', '匹配结尾$', '^全匹配$', '模糊.*匹配。?'],
      reply: {
        type: 'text',
        content: '回复内容1'
      }
    }
  ],
  getAccessToken (callback) {
    callback(access_token)
  },
  onError (err) {
    console.error(err)
  }
}
const reply = new Reply(options)

app.post('/wechat', wechat(config).middlewarify(), reply.middlewarify())

options 对象属性

名称类型必填描述
appIdString微信公众号appId
encodingAESKeyString微信公众号encodingAESKey
tokenString微信公众号token
rulesArray规则数组
getAccessTokenFunction获取微信access_token函数
onErrorFunction错误处理函数

rules

名称类型必填描述
keywordsArray字符串数组。用于生成RegExp对象,因此内容需符合RegExp规则。
replyObject回复内容
seqNumber规则优先级。值越大越靠前。
nameString规则名称

reply

名称类型必填描述
typeString回复内容的格式。支持textimage
contentString回复的内容。

方法

Middlewarify

导出中间件函数。

app.post('/wechat', reply.middlewarify())

updateRules

updateRules(rules) 更新规则。传入新的规则列表会完全覆盖旧的规则。

参数

const Reply = require('@neuroo_fe/wechat-reply')
const reply = new Reply()
reply.updateRules([
  {
    name: '新规则',
    ...
  }
])

Keywords

wechat

FAQs

Package last updated on 16 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.