Skip to content
Browse files

Merge pull request #1 from DeMarko/master

mIRC color support
  • Loading branch information...
2 parents 1bd57df + e2717bc commit 0652984ec4cf8ccf4a760228ab6b49a8862a4be4 @RJ committed May 13, 2011
Showing with 32 additions and 3 deletions.
  1. +32 −3 src/fm/last/irccat/IRCCat.java
View
35 src/fm/last/irccat/IRCCat.java
@@ -181,9 +181,38 @@ public void onPrivateMessage(String sender, String login, String hostname,
handleMessage(null, sender, message);
}
- public void sendMsg(String t, String m) {
- super.sendMessage(t, m);
- }
+ public void sendMsg(String t, String m) {
+ m = mIRCify(m);
+ super.sendMessage(t, m);
+ }
+
+ public String mIRCify(String m) {
+ Map<String, String> colorReplacementMap = new HashMap<String, String>();
+ colorReplacementMap.put("#NORMAL", Colors.NORMAL);
+ colorReplacementMap.put("#BOLD", Colors.BOLD);
+ colorReplacementMap.put("#UNDERLINE", Colors.UNDERLINE);
+ colorReplacementMap.put("#REVERSE", Colors.REVERSE);
+ colorReplacementMap.put("#WHITE", Colors.WHITE);
+ colorReplacementMap.put("#BLACK", Colors.BLACK);
+ colorReplacementMap.put("#DBLUE", Colors.DARK_BLUE);
+ colorReplacementMap.put("#DGREEN", Colors.DARK_GREEN);
+ colorReplacementMap.put("#RED", Colors.RED);
+ colorReplacementMap.put("#BROWN", Colors.BROWN);
+ colorReplacementMap.put("#PURPLE", Colors.PURPLE);
+ colorReplacementMap.put("#ORANGE", Colors.OLIVE);
+ colorReplacementMap.put("#YELLOW", Colors.YELLOW);
+ colorReplacementMap.put("#GREEN", Colors.GREEN);
+ colorReplacementMap.put("#TEAL", Colors.TEAL);
+ colorReplacementMap.put("#CYAN", Colors.CYAN);
+ colorReplacementMap.put("#BLUE", Colors.BLUE);
+ colorReplacementMap.put("#PINK", Colors.MAGENTA);
+ colorReplacementMap.put("#DGRAY", Colors.DARK_GRAY);
+ colorReplacementMap.put("#GRAY", Colors.LIGHT_GRAY);
+
+ for(Map.Entry<String, String> e : colorReplacementMap.entrySet())
+ m = m.replaceAll(e.getKey(), e.getValue());
+ return m;
+ }
// message sent to our channel
public void onMessage(String channel_, String sender, String login,

1 comment on commit 0652984

@DeMarko

oh, I guess this means you can't emit channels named any of those things as they will get replaced with the color codes. using # may have been a mistake.

Please sign in to comment.
Something went wrong with that request. Please try again.