正在显示
6 个修改的文件
包含
91 行增加
和
63 行删除
| @@ -87,6 +87,12 @@ | @@ -87,6 +87,12 @@ | ||
| 87 | <artifactId>guava</artifactId> | 87 | <artifactId>guava</artifactId> |
| 88 | </dependency> | 88 | </dependency> |
| 89 | 89 | ||
| 90 | + <dependency> | ||
| 91 | + <groupId>com.vdurmont</groupId> | ||
| 92 | + <artifactId>emoji-java</artifactId> | ||
| 93 | + <version>5.0.0</version> | ||
| 94 | + </dependency> | ||
| 95 | + | ||
| 90 | </dependencies> | 96 | </dependencies> |
| 91 | 97 | ||
| 92 | <build> | 98 | <build> |
| @@ -2,12 +2,13 @@ package com.crossoverjie.cim.client.service.impl; | @@ -2,12 +2,13 @@ package com.crossoverjie.cim.client.service.impl; | ||
| 2 | 2 | ||
| 3 | import com.crossoverjie.cim.client.client.CIMClient; | 3 | import com.crossoverjie.cim.client.client.CIMClient; |
| 4 | import com.crossoverjie.cim.client.config.AppConfiguration; | 4 | import com.crossoverjie.cim.client.config.AppConfiguration; |
| 5 | -import com.crossoverjie.cim.client.service.*; | 5 | +import com.crossoverjie.cim.client.service.InnerCommand; |
| 6 | +import com.crossoverjie.cim.client.service.InnerCommandContext; | ||
| 7 | +import com.crossoverjie.cim.client.service.MsgHandle; | ||
| 8 | +import com.crossoverjie.cim.client.service.MsgLogger; | ||
| 9 | +import com.crossoverjie.cim.client.service.RouteRequest; | ||
| 6 | import com.crossoverjie.cim.client.vo.req.GroupReqVO; | 10 | import com.crossoverjie.cim.client.vo.req.GroupReqVO; |
| 7 | import com.crossoverjie.cim.client.vo.req.P2PReqVO; | 11 | import com.crossoverjie.cim.client.vo.req.P2PReqVO; |
| 8 | -import com.crossoverjie.cim.client.vo.res.OnlineUsersResVO; | ||
| 9 | -import com.crossoverjie.cim.common.data.construct.TrieTree; | ||
| 10 | -import com.crossoverjie.cim.common.enums.SystemCommandEnum; | ||
| 11 | import com.crossoverjie.cim.common.util.StringUtil; | 12 | import com.crossoverjie.cim.common.util.StringUtil; |
| 12 | import org.slf4j.Logger; | 13 | import org.slf4j.Logger; |
| 13 | import org.slf4j.LoggerFactory; | 14 | import org.slf4j.LoggerFactory; |
| @@ -15,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -15,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 16 | 17 | ||
| 17 | import javax.annotation.Resource; | 18 | import javax.annotation.Resource; |
| 18 | -import java.util.List; | ||
| 19 | import java.util.Map; | 19 | import java.util.Map; |
| 20 | import java.util.concurrent.ThreadPoolExecutor; | 20 | import java.util.concurrent.ThreadPoolExecutor; |
| 21 | import java.util.concurrent.TimeUnit; | 21 | import java.util.concurrent.TimeUnit; |
| @@ -144,63 +144,6 @@ public class MsgHandler implements MsgHandle { | @@ -144,63 +144,6 @@ public class MsgHandler implements MsgHandle { | ||
| 144 | 144 | ||
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | - | ||
| 148 | - /** | ||
| 149 | - * 模糊匹配 | ||
| 150 | - * | ||
| 151 | - * @param msg | ||
| 152 | - */ | ||
| 153 | - private void prefixSearch(String msg) { | ||
| 154 | - try { | ||
| 155 | - List<OnlineUsersResVO.DataBodyBean> onlineUsers = routeRequest.onlineUsers(); | ||
| 156 | - TrieTree trieTree = new TrieTree(); | ||
| 157 | - for (OnlineUsersResVO.DataBodyBean onlineUser : onlineUsers) { | ||
| 158 | - trieTree.insert(onlineUser.getUserName()); | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | - String[] split = msg.split(" "); | ||
| 162 | - String key = split[1]; | ||
| 163 | - List<String> list = trieTree.prefixSearch(key); | ||
| 164 | - | ||
| 165 | - for (String res : list) { | ||
| 166 | - res = res.replace(key, "\033[31;4m" + key + "\033[0m"); | ||
| 167 | - System.out.println(res); | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | - } catch (Exception e) { | ||
| 171 | - LOGGER.error("Exception", e); | ||
| 172 | - } | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - /** | ||
| 176 | - * 查询聊天记录 | ||
| 177 | - * | ||
| 178 | - * @param msg | ||
| 179 | - */ | ||
| 180 | - private void queryChatHistory(String msg) { | ||
| 181 | - String[] split = msg.split(" "); | ||
| 182 | - String res = msgLogger.query(split[1]); | ||
| 183 | - System.out.println(res); | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - /** | ||
| 187 | - * 打印在线用户 | ||
| 188 | - */ | ||
| 189 | - private void printOnlineUsers() { | ||
| 190 | - try { | ||
| 191 | - List<OnlineUsersResVO.DataBodyBean> onlineUsers = routeRequest.onlineUsers(); | ||
| 192 | - | ||
| 193 | - LOGGER.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
| 194 | - for (OnlineUsersResVO.DataBodyBean onlineUser : onlineUsers) { | ||
| 195 | - LOGGER.info("userId={}=====userName={}", onlineUser.getUserId(), onlineUser.getUserName()); | ||
| 196 | - } | ||
| 197 | - LOGGER.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
| 198 | - | ||
| 199 | - } catch (Exception e) { | ||
| 200 | - LOGGER.error("Exception", e); | ||
| 201 | - } | ||
| 202 | - } | ||
| 203 | - | ||
| 204 | /** | 147 | /** |
| 205 | * 关闭系统 | 148 | * 关闭系统 |
| 206 | */ | 149 | */ |
cim-client/src/main/java/com/crossoverjie/cim/client/service/impl/command/EmojiCommand.java
0 → 100644
| 1 | +package com.crossoverjie.cim.client.service.impl.command; | ||
| 2 | + | ||
| 3 | +import com.crossoverjie.cim.client.service.InnerCommand; | ||
| 4 | +import com.vdurmont.emoji.Emoji; | ||
| 5 | +import com.vdurmont.emoji.EmojiManager; | ||
| 6 | +import com.vdurmont.emoji.EmojiParser; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.stereotype.Service; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Function: | ||
| 15 | + * | ||
| 16 | + * @author crossoverJie | ||
| 17 | + * Date: 2019-01-27 19:37 | ||
| 18 | + * @since JDK 1.8 | ||
| 19 | + */ | ||
| 20 | +@Service | ||
| 21 | +public class EmojiCommand implements InnerCommand { | ||
| 22 | + private final static Logger LOGGER = LoggerFactory.getLogger(EmojiCommand.class); | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public void process(String msg) { | ||
| 27 | + String value = msg.split(" ")[1]; | ||
| 28 | + if (value != null) { | ||
| 29 | + Integer index = Integer.parseInt(value); | ||
| 30 | + List<Emoji> all = (List<Emoji>) EmojiManager.getAll(); | ||
| 31 | + all = all.subList(5 * index, 5 * index + 5); | ||
| 32 | + | ||
| 33 | + for (Emoji emoji : all) { | ||
| 34 | + System.out.println(EmojiParser.parseToAliases(emoji.getUnicode()) + "--->" + emoji.getUnicode()); | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + } | ||
| 39 | +} |
| @@ -4,16 +4,24 @@ package com.crossoverjie.cim.server.test; | @@ -4,16 +4,24 @@ package com.crossoverjie.cim.server.test; | ||
| 4 | import com.alibaba.fastjson.JSON; | 4 | import com.alibaba.fastjson.JSON; |
| 5 | import com.crossoverjie.cim.client.vo.res.CIMServerResVO; | 5 | import com.crossoverjie.cim.client.vo.res.CIMServerResVO; |
| 6 | import com.crossoverjie.cim.client.vo.res.OnlineUsersResVO; | 6 | import com.crossoverjie.cim.client.vo.res.OnlineUsersResVO; |
| 7 | +import com.vdurmont.emoji.Emoji; | ||
| 8 | +import com.vdurmont.emoji.EmojiManager; | ||
| 9 | +import com.vdurmont.emoji.EmojiParser; | ||
| 7 | import org.junit.Test; | 10 | import org.junit.Test; |
| 8 | import org.slf4j.Logger; | 11 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; | 12 | import org.slf4j.LoggerFactory; |
| 10 | 13 | ||
| 11 | import java.io.IOException; | 14 | import java.io.IOException; |
| 12 | import java.nio.charset.Charset; | 15 | import java.nio.charset.Charset; |
| 13 | -import java.nio.file.*; | 16 | +import java.nio.file.Files; |
| 17 | +import java.nio.file.LinkOption; | ||
| 18 | +import java.nio.file.Path; | ||
| 19 | +import java.nio.file.Paths; | ||
| 20 | +import java.nio.file.StandardOpenOption; | ||
| 14 | import java.time.LocalDate; | 21 | import java.time.LocalDate; |
| 15 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
| 16 | import java.util.Arrays; | 23 | import java.util.Arrays; |
| 24 | +import java.util.Collection; | ||
| 17 | import java.util.List; | 25 | import java.util.List; |
| 18 | 26 | ||
| 19 | /** | 27 | /** |
| @@ -179,5 +187,24 @@ public class CommonTest { | @@ -179,5 +187,24 @@ public class CommonTest { | ||
| 179 | } catch (IOException e) { | 187 | } catch (IOException e) { |
| 180 | LOGGER.info("IOException", e); | 188 | LOGGER.info("IOException", e); |
| 181 | } | 189 | } |
| 190 | + | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + @Test | ||
| 194 | + public void emoji() throws Exception{ | ||
| 195 | + String str = "An :grinning:awesome :smiley:string 😄with a few :wink:emojis!"; | ||
| 196 | + String result = EmojiParser.parseToUnicode(str); | ||
| 197 | + System.out.println(result); | ||
| 198 | + | ||
| 199 | + | ||
| 200 | + result = EmojiParser.parseToAliases(str); | ||
| 201 | + System.out.println(result); | ||
| 202 | + | ||
| 203 | + Collection<Emoji> all = EmojiManager.getAll(); | ||
| 204 | + for (Emoji emoji : all) { | ||
| 205 | + System.out.println(EmojiParser.parseToAliases(emoji.getUnicode()) + "--->" + emoji.getUnicode() ); | ||
| 206 | + } | ||
| 207 | + | ||
| 182 | } | 208 | } |
| 209 | + | ||
| 183 | } | 210 | } |
| @@ -19,6 +19,7 @@ public enum SystemCommandEnum { | @@ -19,6 +19,7 @@ public enum SystemCommandEnum { | ||
| 19 | AI(":ai ","开启 AI 模式","OpenAIModelCommand"), | 19 | AI(":ai ","开启 AI 模式","OpenAIModelCommand"), |
| 20 | QAI(":qai ","关闭 AI 模式","CloseAIModelCommand"), | 20 | QAI(":qai ","关闭 AI 模式","CloseAIModelCommand"), |
| 21 | PREFIX(":pu ","模糊匹配用户","PrefixSearchCommand"), | 21 | PREFIX(":pu ","模糊匹配用户","PrefixSearchCommand"), |
| 22 | + EMOJI(":emoji ","emoji 表情列表","EmojiCommand"), | ||
| 22 | INFO(":info ","获取客户端信息","EchoInfoCommand") | 23 | INFO(":info ","获取客户端信息","EchoInfoCommand") |
| 23 | 24 | ||
| 24 | ; | 25 | ; |
-
请 注册 或 登录 后发表评论