• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EmojiParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.vdurmont.emoji.EmojiParser的典型用法代码示例。如果您正苦于以下问题:Java EmojiParser类的具体用法?Java EmojiParser怎么用?Java EmojiParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EmojiParser类属于com.vdurmont.emoji包,在下文中一共展示了EmojiParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
                }
    }));
}
 
开发者ID:mzlogin,项目名称:guanggoo-android,代码行数:25,代码来源:NewTopicPresenter.java


示例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);
        }
    }));
}
 
开发者ID:mzlogin,项目名称:guanggoo-android,代码行数:19,代码来源:TopicDetailPresenter.java


示例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);
        }
    }
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:17,代码来源:IRC.java


示例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();
	}
}
 
开发者ID:Bermos,项目名称:kokbot,代码行数:22,代码来源:Karma.java


示例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;
}
 
开发者ID:biezhi,项目名称:wechat-api,代码行数:26,代码来源:WeChatUtils.java


示例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;
}
 
开发者ID:ZHENFENG13,项目名称:My-Blog,代码行数:38,代码来源:ContentServiceImpl.java


示例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;
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:15,代码来源:Config.java


示例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;
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:15,代码来源:Config.java


示例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;
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:15,代码来源:Config.java


示例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();
			}
		}	
	}
}
 
开发者ID:alex321v,项目名称:iln,代码行数:35,代码来源:TelegramIlnBot.java


示例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));
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:9,代码来源:Session.java


示例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);
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:39,代码来源:EtcCommands.java


示例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;
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:8,代码来源:TransformSlackSmileys.java


示例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)))));
}
 
开发者ID:manuelgu,项目名称:DiscordMC,代码行数:15,代码来源:MessageAPI.java


示例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();
	}
}
 
开发者ID:Bermos,项目名称:kokbot,代码行数:31,代码来源:Karma.java


示例16: parseEmojis

import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
/**
 * Replaces emoji codes within the text with unicode emojis.
 *
 * Note that an emoji code must be surrounded on both sides by one of:
 *
 * - whitespace (i.e. ' ' or '\t')
 * - punctuation (one of [.,;:"'?!])
 * - the beginning or end of the string
 */
public static String parseEmojis(String body) {
    if (TextUtils.isEmpty(body)) {
        return body;
    }

    // whitespace and punctuation characters
    String ACCEPTED_CHARS = "[\\s.,?:;'\"!]";

    // explanation: we want to match:
    // 1) either an accepted char or the beginning of the text (i.e. ^)
    // 2) the actual emoji code (to be inserted in the loop)
    // 3) either an accepted char or the end of the text (i.e. $)
    String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS);

    // iterate over all the entries
    for (Map.Entry<String, String> entry : EmojiRegistry.EMOJIS_MAP.entrySet()) {
        // quote the emoji code because some characters like ) are protected in regex land
        String quoted = Pattern.quote(entry.getKey());
        String regex = String.format(REGEX_TEMPLATE, quoted);

        // the $1 and $2 represent the character* that came before the emoji and the
        // character* that came after the emoji
        // * - or beginning / end of text
        body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2");
    }

    return EmojiParser.parseToUnicode(body);
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:38,代码来源:EmojiRegistry.java


示例17: Op

import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
public Op(@NotNull OpType type,
          @Nullable String symbol,
          @Nullable String keyword,
          @NotNull String name,
          boolean reserved,
          boolean reactive,
          @Nullable String bnf,
          int priority,
          @Nullable Boolean pure,
          @NotNull SourceNodeOptions nodeOptions,
          @Nullable String emoji,
          @Nullable Function<Value[], Type> typeFunction) {
    this.type = type;
    this.typeFunction = typeFunction;
    if (emoji != null) {
        this.emoji = EmojiParser.parseToUnicode(emoji);
    }
    this.symbol = symbol;
    this.keyword = keyword;
    this.name = name;
    this.reserved = reserved;
    this.reactive = reactive;
    this.bnf = bnf;
    this.priority = priority;
    this.pure = pure;
    this.nodeOptions = nodeOptions;

    if (!reserved && (priority == 0)) {
        throw new AssertionError("Priority must be > 0");
    }
}
 
开发者ID:sillelien,项目名称:dollar,代码行数:32,代码来源:Op.java


示例18: cleanEntry

import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
private Category cleanEntry(Category category) {
    if (category.getName() != null) {
        category.setName(EmojiParser.parseToAliases(category.getName()));
    }
    if (category.getDescription() != null) {
        category.setDescription(EmojiParser.parseToAliases(category.getDescription()));
    }
    return category;
}
 
开发者ID:rwth-acis,项目名称:RequirementsBazaar,代码行数:10,代码来源:CategoryTransformer.java


示例19: cleanEntry

import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
private Attachment cleanEntry(Attachment attachment) {
    if (attachment.getName() != null) {
        attachment.setName(EmojiParser.parseToAliases(attachment.getName()));
    }
    if (attachment.getDescription() != null) {
        attachment.setDescription(EmojiParser.parseToAliases(attachment.getDescription()));
    }
    return attachment;
}
 
开发者ID:rwth-acis,项目名称:RequirementsBazaar,代码行数:10,代码来源:AttachmentTransformer.java


示例20: cleanEntry

import com.vdurmont.emoji.EmojiParser; //导入依赖的package包/类
private Project cleanEntry(Project project) {
    if (project.getName() != null) {
        project.setName(EmojiParser.parseToAliases(project.getName()));
    }
    if (project.getDescription() != null) {
        project.setDescription(EmojiParser.parseToAliases(project.getDescription()));
    }
    return project;
}
 
开发者ID:rwth-acis,项目名称:RequirementsBazaar,代码行数:10,代码来源:ProjectTransformer.java



注:本文中的com.vdurmont.emoji.EmojiParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IndexNameExpressionResolver类代码示例发布时间:2022-05-21
下一篇:
Java IJarEntryResource类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap