diff options
author | Sven Gothel <[email protected]> | 2013-01-17 18:41:38 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-01-17 18:41:38 +0100 |
commit | 6a64f0358cc24cc9b6e344c99d7fa0c36ca86839 (patch) | |
tree | cfa2cbd6ea7c60fca538c45a5797ab9edfa50614 | |
parent | a1020970b8afa2dd0d97813280f44580f0372bf9 (diff) |
LobBot: Customize 'showHostname' / CatOut: Don't show hostname
-rw-r--r-- | src/org/jogamp/jabot/irc/CatOut.java | 3 | ||||
-rw-r--r-- | src/org/jogamp/jabot/irc/LogBot.java | 26 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/org/jogamp/jabot/irc/CatOut.java b/src/org/jogamp/jabot/irc/CatOut.java index 76436c1..bb53211 100644 --- a/src/org/jogamp/jabot/irc/CatOut.java +++ b/src/org/jogamp/jabot/irc/CatOut.java @@ -35,6 +35,7 @@ public class CatOut extends PircBot { public static void main(String[] args) throws Exception { final String joinMessage = "This channel is logged"; + final boolean showHostname = false; final String login, name, server, channelNoHash; final boolean verbose; final long logrotate; @@ -100,7 +101,7 @@ public class CatOut extends PircBot { htmlFooter= new File(_htmlFooter); } - final LogBot bot = new LogBot(joinMessage, htmlOut); + final LogBot bot = new LogBot(showHostname, joinMessage, htmlOut); bot.setVerbose(verbose); bot.setLoginAndName(login, name); bot.connect(server); diff --git a/src/org/jogamp/jabot/irc/LogBot.java b/src/org/jogamp/jabot/irc/LogBot.java index 4afee5d..e334ae8 100644 --- a/src/org/jogamp/jabot/irc/LogBot.java +++ b/src/org/jogamp/jabot/irc/LogBot.java @@ -24,9 +24,6 @@ import org.jibble.pircbot.PircBot; import org.jogamp.jabot.util.TimeTool;
public class LogBot extends PircBot {
-
- private static final Pattern urlPattern = Pattern.compile("(?i:\\b((http|https|ftp|irc)://[^\\s]+))");
-
public static final String GREEN = "irc-green";
public static final String BLACK = "irc-black";
public static final String BROWN = "irc-brown";
@@ -34,6 +31,12 @@ public class LogBot extends PircBot { public static final String BRICK = "irc-brick";
public static final String RED = "irc-red";
+ private static final Pattern urlPattern = Pattern.compile("(?i:\\b((http|https|ftp|irc)://[^\\s]+))");
+ private static String ANONYMOUS = "anon";
+
+ private final boolean showHostname;
+ private String joinMessage;
+
private final Calendar calendar;
private final Object timeSync = new Object();
@@ -41,14 +44,13 @@ public class LogBot extends PircBot { private final Object outSync = new Object();
private PrintStream out;
- private String joinMessage;
-
- public LogBot(String joinMessage, boolean xmlOut) {
- this(joinMessage, TimeTool.getNearZuluTimeZone(), Locale.getDefault(), System.out, xmlOut);
+ public LogBot(boolean showHostname, String joinMessage, boolean xmlOut) {
+ this(showHostname, joinMessage, TimeTool.getNearZuluTimeZone(), Locale.getDefault(), System.out, xmlOut);
}
- public LogBot(String joinMessage, TimeZone timeZone, Locale locale, PrintStream out, boolean xmlOut) {
- calendar = new GregorianCalendar(timeZone, locale);
+ public LogBot(boolean showHostname, String joinMessage, TimeZone timeZone, Locale locale, PrintStream out, boolean xmlOut) {
+ this.showHostname = showHostname;
+ this.calendar = new GregorianCalendar(timeZone, locale);
this.xmlOut = xmlOut;
this.out = out;
this.joinMessage = joinMessage;
@@ -129,7 +131,7 @@ public class LogBot extends PircBot { }
public void onJoin(String channel, String sender, String login, String hostname) {
- append(GREEN, "* " + sender + " (" + login + "@" + hostname + ") has joined " + channel);
+ append(GREEN, "* " + sender + " (" + login + "@" + ( showHostname ? hostname : ANONYMOUS ) + ") has joined " + channel);
if (sender.equals(getNick())) {
sendNotice(channel, joinMessage);
}
@@ -160,7 +162,7 @@ public class LogBot extends PircBot { }
public void onPart(String channel, String sender, String login, String hostname) {
- append(GREEN, "* " + sender + " (" + login + "@" + hostname + ") has left " + channel);
+ append(GREEN, "* " + sender + " (" + login + "@" + ( showHostname ? hostname : ANONYMOUS ) + ") has left " + channel);
}
public void onPing(String sourceNick, String sourceLogin, String sourceHostname, String target, String pingValue) {
@@ -172,7 +174,7 @@ public class LogBot extends PircBot { }
public void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) {
- append(NAVY, "* " + sourceNick + " (" + sourceLogin + "@" + sourceHostname + ") Quit (" + reason + ")");
+ append(NAVY, "* " + sourceNick + " (" + sourceLogin + "@" + ( showHostname ? sourceHostname : ANONYMOUS ) + ") Quit (" + reason + ")");
}
public void onTime(String sourceNick, String sourceLogin, String sourceHostname, String target) {
|