本文整理汇总了Java中org.pircbotx.Colors.NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Java Colors.NORMAL属性的具体用法?Java Colors.NORMAL怎么用?Java Colors.NORMAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.pircbotx.Colors
的用法示例。
在下文中一共展示了Colors.NORMAL属性的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);
}
}
示例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");
}
}
示例3: getRoxyQuote
public String getRoxyQuote(int line) {
String name = "Roxy";
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);
}
示例4: 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);
}
示例5: getGamzeeQuote
public String getGamzeeQuote(int line) {
String name = "Gamzee";
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);
}
示例6: getJasperspriteQuote
public String getJasperspriteQuote(int line) {
String name = "Jaspersprite";
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);
}
示例7: getCalibornQuote
public String getCalibornQuote(int line) {
String name = "Caliborn";
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);
}
示例8: getEquiusQuote
public String getEquiusQuote(int line) {
String name = "Equius";
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);
}
示例9: getRufiohQuote
public String getRufiohQuote(int line) {
String name = "Rufioh";
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);
}
示例10: McBans
public static String McBans(String user) {
String bans;
int i;
try {
URL url = new URL("http://api.fishbans.com/bans/" + user);
JsonObject banservice = JsonUtils.getJsonObject(IOUtils.toString(url)).getAsJsonObject("bans").getAsJsonObject("service");
i = Integer.parseInt(banservice.getAsJsonObject("mcbans").get("bans").getAsString())
+ Integer.parseInt(banservice.getAsJsonObject("mcbouncer").get("bans").getAsString())
+ Integer.parseInt(banservice.getAsJsonObject("mcblockit").get("bans").getAsString())
+ Integer.parseInt(banservice.getAsJsonObject("minebans").get("bans").getAsString())
+ Integer.parseInt(banservice.getAsJsonObject("glizer").get("bans").getAsString());
if (Integer.valueOf(i).equals(0) || Integer.valueOf(i).equals(1)) {
bans = Colors.BOLD + user + Colors.NORMAL + " has a total of " + Colors.BOLD + i + Colors.NORMAL + " ban!";
} else {
bans = Colors.BOLD + user + Colors.NORMAL + " has a total of " + Colors.BOLD + i + Colors.NORMAL + " bans!";
}
} catch (IOException x) {
x.printStackTrace();
bans = "Please make sure you spelled the Minecraft name right! ";
}
return bans;
}
示例11: getJadespriteQuote
public String getJadespriteQuote(int line) {
String name = "Jadesprite";
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);
}
示例12: getFeferiQuote
public String getFeferiQuote(int line) {
String name = "Feferi";
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);
}
示例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;
}
示例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);
}
}
}
示例15: onMessage
@Override
public void onMessage(MessageEvent event) throws Exception {
if (event.getMessage().startsWith(Helix.botPrefix + Commands.checkMinecraftAccount + " ") && event.getMessage().length() > (Commands.checkMinecraftAccount.length() + 2)) {
String a = event.getMessage().split(" ", 2)[1].replace(" ", "");
String m;
try {
JSONObject r = new JSONObject(Util.getHTTPResponse("https://api.mojang.com/users/profiles/minecraft/" + URLEncoder.encode(a, "UTF-8")));
String name = r.getString("name");
String id = r.getString("id");
JSONArray h = new JSONArray(Util.getHTTPResponse("https://api.mojang.com/user/profiles/" + id + "/names"));
m = "Username: " + Colors.GREEN + name + Colors.NORMAL + " UUID: " + Colors.MAGENTA + id + Colors.NORMAL + " Username history: " + Colors.BLUE + h.getJSONObject(0).getString("name") + Colors.NORMAL;
for (int i = 1; i < h.length(); i++){
m += ", " + Colors.BLUE + h.getJSONObject(i).getString("name") + Colors.NORMAL;
}
} catch (JSONException e) {
m = Colors.RED + "User " + a + " not found!";
}
event.getChannel().send().message(m);
}
}