本文整理汇总了Java中org.pircbotx.Colors.WHITE属性的典型用法代码示例。如果您正苦于以下问题:Java Colors.WHITE属性的具体用法?Java Colors.WHITE怎么用?Java Colors.WHITE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.pircbotx.Colors
的用法示例。
在下文中一共展示了Colors.WHITE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeCommand
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
StringBuilder sb = new StringBuilder("Testing ");
sb.append(StringUtils.getArgs(cmd)).append(": ");
int random = MathUtils.getRandom(0, CHECK_MATH_MAX);
String result;
if (random < CHECK_MATH_PANIC) {
result = Colors.WHITE + "[" + Colors.YELLOW + "PANIC" + Colors.WHITE + "]";
} else if (random < CHECK_MATH_FAIL) {
result = Colors.WHITE + "[" + Colors.RED + "FAIL" + Colors.WHITE + "]";
} else {
result = Colors.WHITE + "[" + Colors.GREEN + "PASS" + Colors.WHITE + "]";
}
sb.append(result);
return new BotResponse(BotIntention.CHAT, event.getUser(), sb.toString());
}
示例2: 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®ionCode=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);
}
}
示例3: executeCommand
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
if (event instanceof MessageEvent) {
Channel channel = ((MessageEvent) event).getChannel();
ImmutableSortedSet<User> users = channel.getUsers();
String victimName = "";
int totalUsers = users.size();
Random random = new Random();
int victimIndex = random.nextInt(totalUsers);
int i = 0;
for (User u : users) {
if (i < victimIndex) {
i++;
} else if (i == victimIndex) {
victimName = u.getNick();
break;
}
}
String message;
if (MathUtils.getRandom(0, DICE_MATH_MAX) < DICE_MATH_MID) {
message = Colors.WHITE + "rolls a huge " + totalUsers + " sided die and it flattens "
+ Colors.YELLOW + victimName + Colors.WHITE + " before coming to a halt on "
+ Colors.RED + "YOU LOSE" + Colors.NORMAL;
} else {
message = Colors.WHITE + "rolls a huge " + totalUsers + " sided die and it lands near "
+ Colors.YELLOW + victimName + Colors.WHITE + " before coming to a halt on "
+ Colors.GREEN + "YOU WIN" + Colors.NORMAL;
}
return new BotResponse(BotIntention.ME, null, message);
} else {
return new BotResponse(BotIntention.PRIVATE_MESSAGE, event.getUser(),
butt.getYamlConfigurationFile().getBotName() + " can't roll no dice here");
}
}