1 package com.foxinmy.weixin4j.example.server.handler;
2
3 import java.util.Set;
4
5 import com.foxinmy.weixin4j.exception.WeixinException;
6 import com.foxinmy.weixin4j.handler.WeixinMessageHandler;
7 import com.foxinmy.weixin4j.request.WeixinMessage;
8 import com.foxinmy.weixin4j.request.WeixinRequest;
9 import com.foxinmy.weixin4j.response.TextResponse;
10 import com.foxinmy.weixin4j.response.WeixinResponse;
11
12
13
14
15
16
17
18
19
20
21 public class CustomMessageHandler implements WeixinMessageHandler {
22
23 @Override
24 public boolean canHandle(WeixinRequest request, WeixinMessage message, Set<String> nodeNames) {
25
26 return message.getFromUserName().equals("xxx");
27 }
28
29 @Override
30 public WeixinResponse doHandle(WeixinRequest request, WeixinMessage messager) {
31 return new TextResponse("是你,是你,还是你。");
32 }
33
34 @Override
35 public int weight() {
36 return 0;
37 }
38 }