本文整理汇总了Java中com.vdurmont.emoji.EmojiParser类的典型用法代码示例。如果您正苦于以下问题:Java EmojiParser类的具体用法?Java EmojiParser怎么用?Java EmojiParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmojiParser类属于com.vdurmont.emoji包,在下文中一共展示了EmojiParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newTopic
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
@Override
public void newTopic(String title, String content) {
mView.startLoading();
title = EmojiParser.parseToAliases(title);
content = EmojiParser.parseToAliases(content);
NetworkTaskScheduler.getInstance().execute(new NewTopicTask(mView.getUrl(),
title,
content,
new OnResponseListener<String>() {
@Override
public void onSucceed(String data) {
mView.stopLoading();
mView.onNewTopicSucceed();
}
@Override
public void onFailed(String msg) {
mView.stopLoading();
mView.onNewTopicFailed(msg);
}
}));
}
示例2: comment
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
@Override
public void comment(String content) {
mView.startLoading();
content = EmojiParser.parseToAliases(content);
NetworkTaskScheduler.getInstance().execute(new CommentTask(getUrl(), content, new OnResponseListener<String>() {
@Override
public void onSucceed(String data) {
mView.stopLoading();
mView.onCommentSucceed();
}
@Override
public void onFailed(String msg) {
mView.stopLoading();
mView.onCommentFailed(msg);
}
}));
}
示例3: onMessage
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
@Override
public void onMessage(String message) {
message = EmojiParser.parseToAliases(message);
if (message.startsWith("PING")) {
sendPong();
}
if (message.startsWith(":") || message.startsWith("@")) {
try {
MessageRunnable messageRunnable = new MessageRunnable(message);
new Thread(messageRunnable).start();
} catch (Exception ex) {
twitchWSIRCParser.parseData(message);
}
}
}
示例4: newUser
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
private void newUser(GuildMessageReceivedEvent event) {
Connection connect = Connections.getConnection();
try {
String name = event.getAuthorName();
if (name != null)
name = EmojiParser.parseToUnicode(name);
String nick = event.getAuthorNick();
if (nick != null)
nick = EmojiParser.parseToUnicode(nick);
PreparedStatement ps = connect.prepareStatement("INSERT INTO users (userid, username, nickname) VALUES (?, ?, ?)");
ps.setString(1, event.getAuthor().getId());
ps.setString(2, name);
ps.setString(3, nick);
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
示例5: emojiParse
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
public static String emojiParse(String text) {
Matcher m = matcher("<span class=\"emoji emoji(.{1,10})\"></span>", text);
StringBuilder sb = new StringBuilder();
int lastStart = 0;
while (m.find()) {
String str = m.group(1);
if (str.length() == 6) {
} else if (str.length() == 10) {
} else {
str = "&#x" + str + ";";
String tmp = text.substring(lastStart, m.start());
sb.append(tmp + str);
lastStart = m.end();
}
}
if (lastStart < text.length()) {
sb.append(text.substring(lastStart));
}
if (sb.length() > 0) {
return EmojiParser.parseToUnicode(sb.toString());
}
return text;
}
示例6: updateArticle
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
@Override
@Transactional
public String updateArticle(ContentVo contents) {
if (null == contents) {
return "文章对象为空";
}
if (StringUtils.isBlank(contents.getTitle())) {
return "文章标题不能为空";
}
if (StringUtils.isBlank(contents.getContent())) {
return "文章内容不能为空";
}
int titleLength = contents.getTitle().length();
if (titleLength > WebConst.MAX_TITLE_COUNT) {
return "文章标题过长";
}
int contentLength = contents.getContent().length();
if (contentLength > WebConst.MAX_TEXT_COUNT) {
return "文章内容过长";
}
if (null == contents.getAuthorId()) {
return "请登录后发布文章";
}
if (StringUtils.isBlank(contents.getSlug())) {
contents.setSlug(null);
}
int time = DateKit.getCurrentUnixTime();
contents.setModified(time);
Integer cid = contents.getCid();
contents.setContent(EmojiParser.parseToAliases(contents.getContent()));
contentDao.updateByPrimaryKeySelective(contents);
relationshipService.deleteById(cid, null);
metasService.saveMetas(cid, contents.getTags(), Types.TAG.getType());
metasService.saveMetas(cid, contents.getCategories(), Types.CATEGORY.getType());
return WebConst.SUCCESS_RESULT;
}
示例7: setGuildReactionOnMention
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
public final Config setGuildReactionOnMention(long guild_id, String reaction_on_mention) {
if (reaction_on_mention == null) {
final ConfigData configData = getConfigData(guild_id, 0, KEY_GUILD_REACTION_ON_MENTION);
if (configData != null) {
configData.delete();
}
return this;
}
if (!reaction_on_mention.startsWith(":") && !reaction_on_mention.endsWith(":")) {
reaction_on_mention = EmojiParser.parseToAliases(reaction_on_mention);
}
setValue(guild_id, 0, KEY_GUILD_REACTION_ON_MENTION, reaction_on_mention);
return this;
}
示例8: setGuildReactionOnCommandNotFound
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
public final Config setGuildReactionOnCommandNotFound(long guild_id, String reaction_on_command_not_found) {
if (reaction_on_command_not_found == null) {
final ConfigData configData = getConfigData(guild_id, 0, KEY_GUILD_REACTION_ON_COMMAND_NOT_FOUND);
if (configData != null) {
configData.delete();
}
return this;
}
if (!reaction_on_command_not_found.startsWith(":") && !reaction_on_command_not_found.endsWith(":")) {
reaction_on_command_not_found = EmojiParser.parseToAliases(reaction_on_command_not_found);
}
setValue(guild_id, 0, KEY_GUILD_REACTION_ON_COMMAND_NOT_FOUND, reaction_on_command_not_found);
return this;
}
示例9: setUserReactionOnCommandNotFound
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
public final Config setUserReactionOnCommandNotFound(long user_id, String reaction_on_command_not_found) {
if (reaction_on_command_not_found == null) {
final ConfigData configData = getConfigData(0, user_id, KEY_USER_REACTION_ON_COMMAND_NOT_FOUND);
if (configData != null) {
configData.delete();
}
return this;
}
if (!reaction_on_command_not_found.startsWith(":") && !reaction_on_command_not_found.endsWith(":")) {
reaction_on_command_not_found = EmojiParser.parseToAliases(reaction_on_command_not_found);
}
setValue(0, user_id, KEY_USER_REACTION_ON_COMMAND_NOT_FOUND, reaction_on_command_not_found);
return this;
}
示例10: onUpdateReceived
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
@Override
public void onUpdateReceived(Update update) {
String line = null;
String prefix, comando, params;
String[] response;
// We check if the update has a message and the message has text
if (update.hasMessage() && update.getMessage().hasText()) {
// Set variables
long chat_id = update.getMessage().getChatId();
mchat = update.getMessage().getChat();
prefix = update.getMessage().getFrom().getUserName();
if (prefix == null) {
prefix = update.getMessage().getFrom().getFirstName();
}
params = nickName + " :" + update.getMessage().getText().toLowerCase().trim();
log.logga(prefix + " --> " + nickName + ": " + update.getMessage().getText().toLowerCase().trim());
response = trattaPrivMsg(prefix, params);
for (int i = 0; i < response.length; i++) {
log.logga(nickName + " --> " + prefix + ": " + response[i]);
SendMessage message = new SendMessage() // Create a message object object
.setChatId(chat_id).setText(EmojiParser.parseToUnicode(response[i]));
try {
sendMessage(message); // Sending our message object to user
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
}
}
示例11: say
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
public void say(String message) {
message = EmojiParser.parseToUnicode(message);
if (message.startsWith(".timeout ")) { //check if the message starts with a "." for timeouts. ".timeout <user>".
sendQueue.add(new Message(message));
return;
}
messages.add(new Message(message));
}
示例12: onMention
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
@EventSubscriber
public void onMention(MentionEvent event) {
IMessage message = event.getMessage();
IChannel channel = event.getMessage().getChannel();
IUser author = event.getMessage().getAuthor();
boolean everyone = message.mentionsEveryone();
boolean dm = channel.isPrivate();
boolean self = event.getClient().getOurUser().equals(author);
if (!everyone && !dm && !self) {
CompletableFuture.runAsync(() -> {
synchronized (lock) {
channel.toggleTypingStatus();
long start = System.currentTimeMillis();
String content = EmojiParser.parseToAliases(message.getContent()
.replace(discordService.getClient().getOurUser().mention(), ""),
EmojiParser.FitzpatrickAction.REMOVE);
try {
String response = chatterBotSessionMap.get(currentSession).think(content);
response = StringEscapeUtils.unescapeHtml4(response);
Matcher matcher = UNICODE.matcher(response);
while (matcher.find()) {
String hex = matcher.group(1);
response = matcher.replaceFirst(new String(Character.toChars(Integer.parseInt(hex, 16))));
}
long delay = System.currentTimeMillis() - start;
log.debug("Response took {} ms", delay);
if (delay < 3000L) {
Thread.sleep(3000L - delay);
}
discordService.sendMessage(channel, author.mention() + " " + response);
} catch (Exception e) {
log.warn("Could not process chatter input", e);
channel.toggleTypingStatus();
}
}
}, taskExecutor);
}
}
示例13: transform
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
@Override
public FirehoseMessage transform(FirehoseMessage firehoseMessage) {
FirehoseMessage msg = (FirehoseMessage) firehoseMessage.clone();
msg.content = msg.content.replaceAll(":slightly_smiling_face:", ":smile:");
msg.content = EmojiParser.parseToUnicode(msg.content);
return msg;
}
示例14: sendToMinecraft
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
/**
* Send a chat message to the Minecraft server
*
* @param origin {@link IChannel} the message came from
* @param username player who sent the message
* @param message the actual message which gets sent
*/
public static void sendToMinecraft(IChannel origin, String username, String message) {
String formattedMessage = getFormattedMessage(origin, username);
DiscordMC.getSubscribedPlayers().forEach(uuid -> Bukkit.getPlayer(uuid).sendMessage(
EmojiParser.parseToAliases(formattedMessage
.replaceAll("%message", ChatColor.stripColor(message)))));
}
示例15: updateUsernames
import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
void updateUsernames(JDA jda) {
Connection connect = Connections.getConnection();
try {
PreparedStatement ps = connect.prepareStatement("SELECT userid FROM users");
ResultSet rs = ps.executeQuery();
ps = connect.prepareStatement("UPDATE users SET username = ?, nickname = ? WHERE userid = ?");
while (rs.next()) {
User user = jda.getUserById(rs.getString("userid"));
if (user != null) {
String name = user.getUsername();
if (name != null)
name = EmojiParser.parseToHtmlHexadecimal(name);
String nick = jda.getGuildById("141575893691793408").getNicknameForUser(user);
if (nick != null)
nick = EmojiParser.parseToHtmlHexadecimal(nick);
ps.setString(1, name);
ps.setString(2, nick);
ps.setString(3, rs.getString("userid"));
ps.addBatch();
}
}
ps.executeBatch();
} catch (SQLException e) {
e.printStackTrace();
}
}