File tree 1 file changed +16
-0
lines changed
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ public class WxMpMessageRouterRule {
25
25
26
26
private String event ;
27
27
28
+ private String eventRegex ;
29
+
28
30
private String eventKey ;
29
31
30
32
private String eventKeyRegex ;
@@ -105,6 +107,18 @@ public WxMpMessageRouterRule eventKeyRegex(String regex) {
105
107
return this ;
106
108
}
107
109
110
+
111
+ /**
112
+ * event匹配该正则表达式
113
+ * 比如"^weapp_audit_.*"用以匹配所有审核类类事件
114
+ *
115
+ * @param regex the regex
116
+ * @return the wx mp message router rule
117
+ */
118
+ public WxMpMessageRouterRule eventRegex (String regex ) {
119
+ this .eventRegex = regex ;
120
+ return this ;
121
+ }
108
122
/**
109
123
* 如果content等于某值
110
124
*
@@ -236,6 +250,8 @@ protected boolean test(WxMpXmlMessage wxMessage) {
236
250
&&
237
251
(this .event == null || this .event .equalsIgnoreCase (wxMessage .getEvent ()))
238
252
&&
253
+ (this .eventRegex == null || Pattern .matches (this .eventRegex , StringUtils .trimToEmpty (wxMessage .getEvent ())))
254
+ &&
239
255
(this .eventKey == null || this .eventKey .equalsIgnoreCase (wxMessage .getEventKey ()))
240
256
&&
241
257
(this .eventKeyRegex == null || Pattern .matches (this .eventKeyRegex , StringUtils .trimToEmpty (wxMessage .getEventKey ())))
You can’t perform that action at this time.
0 commit comments