-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from syl20bnr/master
Added new configuration option to colorize sent messages depending on the current and previous states of job. Thanks !
- Loading branch information
Showing
5 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package hudson.plugins.ircbot.v2; | ||
|
||
import org.pircbotx.Colors; | ||
|
||
/** | ||
* Simple support for IRC colors. | ||
* | ||
* @author syl20bnr | ||
*/ | ||
public class IRCColor { | ||
|
||
private final String message; | ||
|
||
public IRCColor(String message) { | ||
this.message = message; | ||
} | ||
|
||
public String colorize(){ | ||
String color = Colors.DARK_GRAY; | ||
if(this.message.startsWith("Starting")){ | ||
if (this.message.contains("FAIL")){ | ||
color = Colors.BROWN; | ||
} | ||
else if (this.message.contains("FIXED")){ | ||
color = Colors.OLIVE; | ||
} | ||
else{ | ||
color = Colors.DARK_GREEN; | ||
} | ||
} | ||
else if(this.message.contains("FIXED")){ | ||
color = Colors.REVERSE + Colors.BOLD + Colors.GREEN; | ||
} | ||
else if(this.message.contains("SUCCESS")){ | ||
color = Colors.BOLD + Colors.GREEN; | ||
} | ||
else if(this.message.contains("FAILURE")){ | ||
color = Colors.REVERSE + Colors.BOLD + Colors.RED; | ||
} | ||
else if(this.message.contains("STILL FAILING")){ | ||
color = Colors.BOLD + Colors.RED; | ||
} | ||
return color + this.message; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div> | ||
<p> | ||
Checking this box allows the bot to send colorized messages depending on the | ||
current and previous states of a job. | ||
|
||
The bot tries to send <font color="green">green messages</font> for successful jobs | ||
and <font color="red">red messages</font> for failures <em> but this may not be right | ||
if your IRC client has defined a custom theme of colors.</em> | ||
</p> | ||
<p> | ||
Here are the rules for coloring messages: | ||
<ul> | ||
<li>Starting previously successful job: <font color="green">green</font></li> | ||
<li>Starting previously fixed job: <font color="olive">olive</font></li> | ||
<li>Starting previously failed job: <font color="red">red</font></li> | ||
<li>First successful build (fixed job): <font color="black" style="background-color: green"><strong>green background</strong></font></li> | ||
<li>First failure: <font color="black" style="background-color: red"><strong>red background</strong></font></li> | ||
<li>Still successful job: <font color="green"><strong>bold green</strong></font></li> | ||
<li>Still failing job: <font color="red"><strong>bold red</strong></font></li> | ||
<li>Default message: <font color="darkgray"><strong>bold gray</strong></font></li> | ||
</ul> | ||
|
||
There is no support for colorblind theme for now. | ||
</p> | ||
</div> |