Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

企业微信服务商模式,消息接收路由规则无法使用msgType等方法 #1909

Closed
ezsky opened this issue Dec 7, 2020 · 1 comment
Milestone

Comments

@ezsky
Copy link

ezsky commented Dec 7, 2020

简要描述

无法使用这几个方法,看源码里面也去掉了,这种情况是怎么做条件筛选的。
.msgType("MSG_TYPE").event("EVENT").eventKey("EVENT_KEY").content("CONTENT")

模块版本情况

  • WxJava 模块名: cp
  • WxJava 版本号:4.0.0

详细描述

类 WxCpTpMessageRouter

java.lang.Object
me.chanjar.weixin.cp.tp.message.WxCpTpMessageRouter

public class WxCpTpMessageRouter
extends Object
微信消息路由器,通过代码化的配置,把来自微信的消息交给handler处理
和WxCpMessageRouter的rule相比,多了infoType和changeType维度的匹配

说明:

  1. 配置路由规则时要按照从细到粗的原则,否则可能消息可能会被提前处理
  2. 默认情况下消息只会被处理一次,除非使用 WxCpTpMessageRouterRule.next()
  3. 规则的结束必须用WxCpTpMessageRouterRule.end()或者WxCpTpMessageRouterRule.next(),否则不会生效

使用方法:
WxCpTpMessageRouter router = new WxCpTpMessageRouter();
router
.rule()
.msgType("MSG_TYPE").event("EVENT").eventKey("EVENT_KEY").content("CONTENT")
.interceptor(interceptor, ...).handler(handler, ...)
.end()
.rule()
.infoType("INFO_TYPE").changeType("CHANGE_TYPE")
// 另外一个匹配规则
.end()
;

// 将WxXmlMessage交给消息路由器
router.route(message);

@Gyv12345
Copy link

配置路由规则时要按照从细到粗的原则,否则可能消息可能会被提前处理 这句话很重要

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants