mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🎨 #3324 【公众号】消息路由规则的事件增加正则匹配支持
This commit is contained in:
parent
497aefe07f
commit
726269988a
@ -25,6 +25,8 @@ public class WxMpMessageRouterRule {
|
||||
|
||||
private String event;
|
||||
|
||||
private String eventRegex;
|
||||
|
||||
private String eventKey;
|
||||
|
||||
private String eventKeyRegex;
|
||||
@ -105,6 +107,18 @@ public class WxMpMessageRouterRule {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* event匹配该正则表达式
|
||||
* 比如"^weapp_audit_.*"用以匹配所有审核类类事件
|
||||
*
|
||||
* @param regex the regex
|
||||
* @return the wx mp message router rule
|
||||
*/
|
||||
public WxMpMessageRouterRule eventRegex(String regex) {
|
||||
this.eventRegex = regex;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* 如果content等于某值
|
||||
*
|
||||
@ -236,6 +250,8 @@ public class WxMpMessageRouterRule {
|
||||
&&
|
||||
(this.event == null || this.event.equalsIgnoreCase(wxMessage.getEvent()))
|
||||
&&
|
||||
(this.eventRegex == null || Pattern.matches(this.eventRegex, StringUtils.trimToEmpty(wxMessage.getEvent())))
|
||||
&&
|
||||
(this.eventKey == null || this.eventKey.equalsIgnoreCase(wxMessage.getEventKey()))
|
||||
&&
|
||||
(this.eventKeyRegex == null || Pattern.matches(this.eventKeyRegex, StringUtils.trimToEmpty(wxMessage.getEventKey())))
|
||||
|
Loading…
Reference in New Issue
Block a user