当前位置: 首页>>代码示例>>Java>>正文


Java Colors.BOLD属性代码示例

本文整理汇总了Java中org.pircbotx.Colors.BOLD属性的典型用法代码示例。如果您正苦于以下问题:Java Colors.BOLD属性的具体用法?Java Colors.BOLD怎么用?Java Colors.BOLD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.pircbotx.Colors的用法示例。


在下文中一共展示了Colors.BOLD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessage

@Override
public void onMessage(MessageEvent event) throws Exception {
    String msg = event.getMessage();
    if (msg.startsWith(Helix.botPrefix + Commands.googleSearch) && ((msg.length() > (Commands.googleSearch.length() + 2) && msg.charAt(Commands.googleSearch.length()+1) == ' ') || (msg.length() > (Commands.googleSearch.length()+3) && Arrays.asList(Helix.valid).contains(msg.charAt(Commands.googleSearch.length()+1)) && msg.charAt(Commands.googleSearch.length()+2) == ' '))) {
        String q = msg.split(" ", 2)[1];
        String max = msg.charAt(Commands.googleSearch.length()+1) == ' ' ? "1" : String.valueOf(msg.charAt(Commands.googleSearch.length()+1));

        String a = "https://www.googleapis.com/customsearch/v1?fields=items(htmlTitle,link,htmlSnippet)&alt=json&key=" + Helix.properties.getProperty("google.apikey") + "&cx=" + Helix.properties.getProperty("google.searchengineid") + "&q=" + URLEncoder.encode(q, "UTF-8");

        String m;
        try {
            JSONObject r = new JSONObject(Util.getHTTPResponse(a)).getJSONArray("items").getJSONObject(Integer.parseInt(max) - 1);
            String title = StringEscapeUtils.unescapeHtml4(r.getString("htmlTitle").replace("<b>", Colors.BOLD).replace("</b>", Colors.NORMAL));
            String link = r.getString("link");
            String snip = StringEscapeUtils.unescapeHtml4(r.getString("htmlSnippet").replace("<b>", Colors.BOLD).replace("</b>", Colors.NORMAL).replace("\n", "").replace("<br>", ""));

            m = "[" + title + "]" + snip + " " + link;

        } catch (JSONException e) {
            m = "No results found for \"" + Colors.BOLD + q + Colors.NORMAL + "\"";
        }

        event.getChannel().send().message(m);
    }

}
 
开发者ID:MatheusVigaro,项目名称:Helix,代码行数:26,代码来源:ListenerCommandGoogle.java

示例2: formatCoinRequest

/**
 * Handles the formatting for the bot's coin request.
 *
 * @param currency The list of currencies retrieved from the coinmarketcap API.
 * @param nf       The NumberFormat instance for formatting currencies.
 * @return The bot's formatted response.
 */
private BotResponse formatCoinRequest(final List<CoinMarketCapResponse> currency, final NumberFormat nf) {
    String dayChange = getColoredChangeText(currency.get(0).getPercentChange24h());
    String hourChange = getColoredChangeText(currency.get(0).getPercentChange1h());
    String weekChange = getColoredChangeText(currency.get(0).getPercentChange7d());

    if (currency.get(0).getMarketCapUsd() != null) {

        return new BotResponse(BotIntention.CHAT, null, Colors.CYAN + Colors.BOLD
                + currency.get(0).getName() + Colors.NORMAL + Colors.TEAL + ": "
                + nf.format(Double.valueOf(currency.get(0).getPriceUsd())) + " | Rank: "
                + currency.get(0).getRank() + Colors.TEAL + " | Market Cap: "
                + nf.format(Double.valueOf(currency.get(0).getMarketCapUsd())),
                Colors.TEAL
                        + "[Hour " + hourChange + "] | [Day " + dayChange + "] | [Week " + weekChange + "]");
    } else {
        return new BotResponse(BotIntention.CHAT, null, Colors.CYAN + Colors.BOLD
                + currency.get(0).getName() + Colors.NORMAL + Colors.TEAL + ": "
                + nf.format(Double.valueOf(currency.get(0).getPriceUsd()))
                + " | Rank: " + currency.get(0).getRank()
                + " | [" + dayChange + "] ",
                "Market Cap: N/A");
    }
}
 
开发者ID:proxa,项目名称:IRCbutt,代码行数:30,代码来源:CryptocurrencyCommand.java

示例3: getAradiaQuote

public String getAradiaQuote(int line) {
	String name = "Aradia";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例4: getLatulaQuote

public String getLatulaQuote(int line) {
	String name = "Latula";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例5: getDragonspriteQuote

public String getDragonspriteQuote(int line) {
	String name = "Dragonsprite";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例6: getJohnQuote

public String getJohnQuote(int line) {
	String name = "John";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例7: getHorussQuote

public String getHorussQuote(int line) {
	String name = "Horuss";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例8: getEridanQuote

public String getEridanQuote(int line) {
	String name = "Eridan";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例9: getNannaspriteQuote

public String getNannaspriteQuote(int line) {
	String name = "Nannasprite";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例10: getSquarewaveQuote

public String getSquarewaveQuote(int line) {
	String name = "Squarewave";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例11: getSolluxQuote

public String getSolluxQuote(int line) {
	String name = "Sollux";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例12: getMitunaQuote

public String getMitunaQuote(int line) {
	String name = "Mituna";
	File FILE = new File("./files/quotes/" + name.toLowerCase() + "-quotes.txt");
	if(!FILE.exists()) {
		try {
			Downloader.downloadFile(new URL(FILE_BASE + "/quotes/" + FILE.getName()), FILE);
		} catch (MalformedURLException e) {
			logger.error("COULD NOT DOWNLOAD " + name.toUpperCase() + " FROM \"" + FILE_BASE + "/quotes/" + FILE.getName() + "\"", e);
		}
	}
	int numOfLines = FileHelper.countLines(FILE);
	if (line > numOfLines) {
		return "Please enter a number from 1-" + numOfLines;
	}
	return Colors.TEAL + Colors.BOLD + "Quote #" + line + " - " + Colors.NORMAL + FileHelper.readLine(FILE, line);
}
 
开发者ID:KazeEspada,项目名称:IRCBot,代码行数:16,代码来源:QuoteHandler.java

示例13: performSearch

private String performSearch(String filter, String terms) {
	try {
		StringBuilder searchURLString = new StringBuilder();
		searchURLString.append("https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=");
		if (filter != null) {
			searchURLString.append(filter).append("+");
		}
		searchURLString.append(terms.replace(" ", "+"));
		URL searchURL = new URL(searchURLString.toString());
		URLConnection conn = searchURL.openConnection();
		conn.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 RavenBot/2.0");
		BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
		StringBuilder json = new StringBuilder();
		String line;
		while ((line = in.readLine()) != null) {
			json.append(line).append("\n");
		}
		in.close();
		JsonElement element = new JsonParser().parse(json.toString());
		JsonObject output = element.getAsJsonObject().getAsJsonObject("responseData").getAsJsonArray("results").get(0).getAsJsonObject();
		String title = StringEscapeUtils.unescapeJava(StringEscapeUtils.unescapeHtml4(output.get("titleNoFormatting").toString().replaceAll("\"", "")));
		String content = StringEscapeUtils.unescapeJava(StringEscapeUtils.unescapeHtml4(output.get("content").toString().replaceAll("\\s+", " ").replaceAll("\\<.*?>", "").replaceAll("\"", "")));
		String url = StringEscapeUtils.unescapeJava(StringEscapeUtils.unescapeHtml4(output.get("url").toString()).replaceAll("\"", ""));
		return url + " - " + Colors.BOLD + title + Colors.NORMAL + ": \"" + content + "\"";
	} catch (IOException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:29,代码来源:SearchHandler.java

示例14: onMessage

@Override
public void onMessage(MessageEvent event) throws Exception {
    if (event.getMessage().startsWith(Helix.botPrefix)) {
        String[] s = event.getMessage().split(" ", 2);
        String command = s[0].substring(1).toLowerCase();
        if (Helix.commands.has(command)) {
            String m = s.length > 1 ? Colors.BOLD + StringUtils.join(s[1].split(" ")) + Colors.NORMAL + ": " + Helix.commands.getString(command) : Helix.commands.getString(command);
            event.getChannel().send().message(m);

        }
    }
}
 
开发者ID:MatheusVigaro,项目名称:Helix,代码行数:12,代码来源:ListenerCommandCustom.java

示例15: onMessage

@Override
public void onMessage(MessageEvent event) throws Exception {
    String msg = event.getMessage();
    if (msg.startsWith(Helix.botPrefix + Commands.youTubeSearch) && ((msg.length() > (Commands.youTubeSearch.length()+2) && msg.charAt(Commands.youTubeSearch.length()+1) == ' ') || (msg.length() > (Commands.youTubeSearch.length()+3) && Arrays.asList(Helix.valid).contains(msg.charAt(Commands.youTubeSearch.length()+1)) && msg.charAt(Commands.youTubeSearch.length()+2) == ' '))){
        String q = msg.split(" ", 2)[1];
        String max = msg.charAt(3) == ' ' ? "1" : String.valueOf(msg.charAt(3));


        String a = String.format("https://www.googleapis.com/youtube/v3/search?part=id&maxResults=%s&regionCode=br&type=video&q=%s&key=%s", max, URLEncoder.encode(q, "UTF-8"), Helix.properties.get("google.apikey"));

        JSONObject v;
        JSONObject snip;
        String views;
        String dislike;
        String like;
        String len;
        String m;
        try {
            v = new JSONObject(Util.getHTTPResponse(String.format("https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,statistics&id=%s&key=%s", (new JSONObject(Util.getHTTPResponse(a))).getJSONArray("items").getJSONObject(Integer.valueOf(max) - 1).getJSONObject("id").getString("videoId"), Helix.properties.get("google.apikey")))).getJSONArray("items").getJSONObject(0);

            snip = v.getJSONObject("snippet");
            JSONObject stat = v.getJSONObject("statistics");

            views = Helix.numberFormat.format(Long.parseLong(stat.getString("viewCount")));
            dislike = Helix.numberFormat.format(Integer.parseInt(stat.getString("dislikeCount")));
            like = Helix.numberFormat.format(Integer.parseInt(stat.getString("likeCount")));
            len = v.getJSONObject("contentDetails").getString("duration");
            m = Colors.BOLD + Colors.BLACK + ",00[You" + Colors.WHITE + ",04Tube]" + Colors.NORMAL + " " + snip.getString("title") + " [" + Colors.OLIVE + (len.equals("PT0S")? "Live" : Util.parseYouTubeTime(len)) + Colors.NORMAL + "] [" + Colors.TEAL + views + Colors.NORMAL + "] [" + Colors.DARK_GREEN + "+" + like + Colors.NORMAL + "] [" + Colors.RED + "-" + dislike + Colors.NORMAL + "] [" + Colors.MAGENTA + snip.getString("channelTitle") + Colors.NORMAL + "] http://youtu.be/" + v.getString("id");
        } catch (JSONException e){
            m = "Video not found! \"" + Colors.BOLD + q + Colors.NORMAL + "\"";
        }

        event.getChannel().send().message(m);


    }
}
 
开发者ID:MatheusVigaro,项目名称:Helix,代码行数:37,代码来源:ListenerCommandYouTubeSearch.java


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