🎨 #3324 【公众号】消息路由规则的事件增加正则匹配支持

This commit is contained in:
zhangruhong 2024-07-10 10:55:11 +08:00 committed by GitHub
parent 497aefe07f
commit 726269988a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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())))