LogBot 0.1.0: Patches for mflogbot (2005-11-16) SUMMARY This patch reflects the the changes to LogBot made for "mflogbot". The latest version can be found on http://rbach.priv.at/Patches/ AUTHOR Robert Bachmann APPLY THE PATCH wget http://www.jibble.org/files/LogBot-0.1.0.zip unzip LogBot-0.1.0.zip wget http://rbach.priv.at/Patches/LogBot-20051116.diff patch -p0 < LogBot-20051116.diff cd org/jibble/logbot javac -classpath .:../../../lib/pircbot.jar LogBot.java LogBotMain.java NOTES (added 2005-11-22) --- org/jibble/logbot/LogBot.java 2004-05-28 19:17:24.000000000 +0200 +++ org/jibble/logbot/LogBot.java 2005-11-16 19:29:01.741245152 +0100 @@ -10,40 +10,88 @@ private static final Pattern urlPattern = Pattern.compile("(?i:\\b((http|https|ftp|irc)://[^\\s]+))"); private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("H:mm"); - - public static final String GREEN = "irc-green"; - public static final String BLACK = "irc-black"; - public static final String BROWN = "irc-brown"; - public static final String NAVY = "irc-navy"; - public static final String BRICK = "irc-brick"; - public static final String RED = "irc-red"; + private static final SimpleDateFormat LINKTIME_FORMAT = new SimpleDateFormat("'T'HH:mm:ss"); + private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat + ("''HH:mm:ss''" ); + + public static final int ACTION = 0; + public static final int JOIN = 1; + public static final int KICK = 2; + public static final int MESSAGE = 3; + public static final int MODE = 4; + public static final int NICK = 5; + public static final int NOTICE = 6; + public static final int PART = 7; + public static final int QUIT = 8; + public static final int TOPIC = 9; + public static final int TOPIC_CHANGE = 10; + private String old_linktime = ""; /* this should be local to append() */ + public LogBot(String name, File outDir, String joinMessage) { setName(name); setVerbose(true); this.outDir = outDir; this.joinMessage = joinMessage; + DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); + TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); + LINKTIME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); } - - public void append(String color, String line) { + + public void append(int type, String line, String s) { line = Colors.removeFormattingAndColors(line); line = line.replaceAll("&", "&"); line = line.replaceAll("<", "<"); - line = line.replaceAll(">", ">"); - + line = line.replaceAll(">", ">"); + Matcher matcher = urlPattern.matcher(line); line = matcher.replaceAll("$1"); - - + try { Date now = new Date(); String date = DATE_FORMAT.format(now); String time = TIME_FORMAT.format(now); + String linktime = LINKTIME_FORMAT.format(now); + File file = new File(outDir, date + ".log"); BufferedWriter writer = new BufferedWriter(new FileWriter(file, true)); - String entry = "[" + time + "] " + line + "
"; + + String entry = "
  • [" + time; + else + entry += "\">[" + time + ""; + + old_linktime = linktime; + + if (type != MESSAGE) { + entry += "] " + line + "
  • "; + } else { + s = Colors.removeFormattingAndColors(s); + s = s.replaceAll("&", "&"); + s = s.replaceAll("<", "<"); + s = s.replaceAll(">", ">"); + + entry += "] <" + s + "> " + line + ""; + } + writer.write(entry); writer.newLine(); writer.flush(); @@ -55,83 +103,72 @@ } public void onAction(String sender, String login, String hostname, String target, String action) { - append(BRICK, "* " + sender + " " + action); + append(ACTION, "* " + sender + " " + action,""); } public void onJoin(String channel, String sender, String login, String hostname) { - append(GREEN, "* " + sender + " (" + login + "@" + hostname + ") has joined " + channel); - if (sender.equals(getNick())) { - sendNotice(channel, joinMessage); - } - else { - sendNotice(sender, joinMessage); - } + append(JOIN, "* " + sender + " (" + login + "@" + hostname + ") has joined " + channel,""); } public void onMessage(String channel, String sender, String login, String hostname, String message) { - append(BLACK, "<" + sender + "> " + message); - - message = message.toLowerCase(); - if (message.startsWith(getNick().toLowerCase()) && message.indexOf("help") > 0) { - sendMessage(channel, joinMessage); - } + append(MESSAGE,message,sender); } public void onMode(String channel, String sourceNick, String sourceLogin, String sourceHostname, String mode) { - append(GREEN, "* " + sourceNick + " sets mode " + mode); + append(MODE, "* " + sourceNick + " sets mode " + mode,""); } public void onNickChange(String oldNick, String login, String hostname, String newNick) { - append(GREEN, "* " + oldNick + " is now known as " + newNick); + append(NICK, "* " + oldNick + " is now known as " + newNick,""); } public void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) { - append(BROWN, "-" + sourceNick + "- " + notice); +// append(NOTICE, "-" + sourceNick + "- " + notice,""); } public void onPart(String channel, String sender, String login, String hostname) { - append(GREEN, "* " + sender + " (" + login + "@" + hostname + ") has left " + channel); + append(PART, "* " + sender + " (" + login + "@" + hostname + ") has left " + channel,""); } public void onPing(String sourceNick, String sourceLogin, String sourceHostname, String target, String pingValue) { - append(RED, "[" + sourceNick + " PING]"); + ; } public void onPrivateMessage(String sender, String login, String hostname, String message) { - append(BLACK, "<- *" + sender + "* " + message); + ; } public void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) { - append(NAVY, "* " + sourceNick + " (" + sourceLogin + "@" + sourceHostname + ") Quit (" + reason + ")"); + append(QUIT, "* " + sourceNick + " (" + sourceLogin + "@" + sourceHostname + ") Quit (" + reason + ")",""); } public void onTime(String sourceNick, String sourceLogin, String sourceHostname, String target) { - append(RED, "[" + sourceNick + " TIME]"); + ; } public void onTopic(String channel, String topic, String setBy, long date, boolean changed) { if (changed) { - append(GREEN, "* " + setBy + " changes topic to '" + topic + "'"); + append(TOPIC_CHANGE, "* " + setBy + " changes topic to '" + topic + "'",""); } else { - append(GREEN, "* Topic is '" + topic + "'"); - append(GREEN, "* Set by " + setBy + " on " + new Date(date)); + append(TOPIC, "* Topic is '" + topic + "'",""); + append(TOPIC, "* Set by " + setBy + " on " + new Date(date),""); } } public void onVersion(String sourceNick, String sourceLogin, String sourceHostname, String target) { - append(RED, "[" + sourceNick + " VERSION]"); + ; } public void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) { - append(GREEN, "* " + recipientNick + " was kicked from " + channel + " by " + kickerNick); - if (recipientNick.equalsIgnoreCase(getNick())) { + append(KICK, "* " + recipientNick + " was kicked from " + channel + " by " + kickerNick,""); + /* if (recipientNick.equalsIgnoreCase(getNick())) { joinChannel(channel); - } + } */ } public void onDisconnect() { - append(NAVY, "* Disconnected."); + // append(DISCONNECT, "* Disconnected."); while (!isConnected()) { try { reconnect(); @@ -163,4 +200,4 @@ private File outDir; private String joinMessage; -} \ No newline at end of file +} --- org/jibble/logbot/LogBotMain.java 2004-05-28 19:08:32.000000000 +0200 +++ org/jibble/logbot/LogBotMain.java 2005-11-16 19:32:43.962600040 +0100 @@ -13,6 +13,7 @@ String server = p.getProperty("Server", "localhost"); String channel = p.getProperty("Channel", "#test"); String nick = p.getProperty("Nick", "LogBot"); + String password = p.getProperty("Password", ""); String joinMessage = p.getProperty("JoinMessage", "This channel is logged."); File outDir = new File(p.getProperty("OutputDir", "./output/")); @@ -40,8 +41,8 @@ writer.close(); LogBot bot = new LogBot(nick, outDir, joinMessage); - bot.connect(server); + bot.connect(server,6667,password); bot.joinChannel(channel); } -} \ No newline at end of file +} --- html/footer.inc.php 2004-05-28 19:19:02.000000000 +0200 +++ html/footer.inc.php 2005-11-16 20:10:33.755838520 +0100 @@ -3,7 +3,7 @@ "> using the Java IRC LogBot.

    - +

    See http://microformats.org/wiki/mflogbot for more information.

    - \ No newline at end of file + diff -u html/header.inc.php html2/header.inc.php --- html/header.inc.php 2004-05-28 17:13:30.000000000 +0200 +++ html2/header.inc.php 2005-11-16 20:14:56.086958128 +0100 @@ -16,19 +16,24 @@ --- html/index.php 2004-05-29 19:09:04.000000000 +0200 +++ html/index.php 2005-11-16 20:15:17.730667784 +0100 @@ -7,20 +7,20 @@ if (isset($date) && preg_match("/^\d\d\d\d-\d\d-\d\d$/", $date)) { ?> -

    +

    Index -

    +

    IRC Log for

    - Timestamps are in GMT/BST. + Timestamps are in UTC.

    -

    +

      -

      +
    - + \ No newline at end of file +?>