作者 crossoverJie

:recycle: 重构代码

@@ -42,9 +42,8 @@ public class Scan implements Runnable { @@ -42,9 +42,8 @@ public class Scan implements Runnable {
42 GoogleProtocolVO vo; 42 GoogleProtocolVO vo;
43 while (true) { 43 while (true) {
44 String msg = sc.nextLine(); 44 String msg = sc.nextLine();
45 - if (StringUtil.isEmpty(msg)){  
46 - LOGGER.warn("不能发送空消息!");  
47 - continue ; 45 + if (checkMsg(msg)) {
  46 + continue;
48 } 47 }
49 48
50 //单聊 49 //单聊
@@ -68,4 +67,17 @@ public class Scan implements Runnable { @@ -68,4 +67,17 @@ public class Scan implements Runnable {
68 LOGGER.info("{}:【{}】", configuration.getUserName(), msg); 67 LOGGER.info("{}:【{}】", configuration.getUserName(), msg);
69 } 68 }
70 } 69 }
  70 +
  71 + /**
  72 + * 校验消息
  73 + * @param msg
  74 + * @return 不能为空,后续可以加上一些敏感词
  75 + */
  76 + private boolean checkMsg(String msg) {
  77 + if (StringUtil.isEmpty(msg)){
  78 + LOGGER.warn("不能发送空消息!");
  79 + return true;
  80 + }
  81 + return false;
  82 + }
71 } 83 }