/** * 判断是否包含关键字,并返回关键字对应的回复内容 * * @param keyword * @return */ private String robotMsgByKeyword(String keyword, String openId) { if (keyword == null) return null; List<RobotMsg> robotMsgs = this.robotMsgRepository.findAll(); for (RobotMsg robotMsg : robotMsgs) { String keywords = robotMsg.getKeyword(); if (Arrays.asList(keywords.split(";")).contains(keyword)) { return this.parseTxt(robotMsg.getContent(), openId); } } return null; }
private String robotMsgByEventKey(String prefix, String eventKey) { List<RobotMsg> robotMsgs = this.robotMsgRepository.findAll(); // 根据不同的渠道回复该渠道对应的信息 for (RobotMsg robotMsg : robotMsgs) { String keywords = robotMsg.getKeyword(); if (Arrays.asList(keywords.split(";")).contains(prefix + eventKey)) { return this.fillEventKey(robotMsg.getContent(), eventKey); } } // 如果渠道没有找到回复信息,统一回复关注信息 String keyword = "关注"; for (RobotMsg robotMsg : robotMsgs) { String keywords = robotMsg.getKeyword(); if (Arrays.asList(keywords.split(";")).contains(keyword)) { return this.fillEventKey(robotMsg.getContent(), eventKey); } } return null; }