From 6a64f0358cc24cc9b6e344c99d7fa0c36ca86839 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Jan 2013 18:41:38 +0100 Subject: LobBot: Customize 'showHostname' / CatOut: Don't show hostname --- src/org/jogamp/jabot/irc/LogBot.java | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/org/jogamp/jabot/irc/LogBot.java') 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) { -- cgit v1.2.3