diff --git a/buildnum.properties b/buildnum.properties
index e2384e0..151aaa4 100644
--- a/buildnum.properties
+++ b/buildnum.properties
@@ -1,3 +1,3 @@
#ANT Task: ch.oscg.jreleaseinfo.BuildNumberHandler
-#Wed Jul 18 23:09:10 PDT 2007
-build.num.last=70
+#Thu Oct 11 16:35:17 PDT 2007
+build.num.last=72
diff --git a/lib/ws-commons-util-1.0.2.jar b/lib/ws-commons-util-1.0.2.jar
new file mode 100644
index 0000000..3fc364e
Binary files /dev/null and b/lib/ws-commons-util-1.0.2.jar differ
diff --git a/lib/xmlrpc-client-3.1.jar b/lib/xmlrpc-client-3.1.jar
new file mode 100644
index 0000000..a76e6ec
Binary files /dev/null and b/lib/xmlrpc-client-3.1.jar differ
diff --git a/lib/xmlrpc-common-3.1.jar b/lib/xmlrpc-common-3.1.jar
new file mode 100644
index 0000000..862098b
Binary files /dev/null and b/lib/xmlrpc-common-3.1.jar differ
diff --git a/mobibot.iml b/mobibot.iml
index e2b6c5b..adbd570 100644
--- a/mobibot.iml
+++ b/mobibot.iml
@@ -162,6 +162,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mobibot.iws b/mobibot.iws
index b2ea451..cc6c099 100644
--- a/mobibot.iws
+++ b/mobibot.iws
@@ -18,7 +18,11 @@
+
+
+
+
@@ -132,7 +136,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -148,10 +161,19 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
@@ -160,16 +182,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -178,7 +191,7 @@
-
+
@@ -187,7 +200,7 @@
-
+
@@ -196,7 +209,7 @@
-
+
@@ -205,7 +218,7 @@
-
+
@@ -214,7 +227,7 @@
-
+
@@ -223,7 +236,7 @@
-
+
@@ -232,7 +245,7 @@
-
+
@@ -292,10 +305,6 @@
-
-
-
-
@@ -378,7 +387,7 @@
-
+
@@ -461,7 +470,7 @@
-
+
@@ -481,25 +490,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -529,6 +519,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -546,6 +555,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -647,7 +674,7 @@
-
+
@@ -752,7 +779,7 @@
-
+
@@ -772,72 +799,79 @@
-
-
-
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/src/net/thauvin/erik/mobibot/Jaiku.java b/src/net/thauvin/erik/mobibot/Jaiku.java
new file mode 100644
index 0000000..f2ac6b4
--- /dev/null
+++ b/src/net/thauvin/erik/mobibot/Jaiku.java
@@ -0,0 +1,100 @@
+/*
+ * @(#)Jaiku.java
+ *
+ * Copyright (C) 2007 Erik C. Thauvin
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+package net.thauvin.erik.mobibot;
+
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Inserts presence information into Jaiku.
+ *
+ * @author Erik C. Thauvin
+ * @version $Revision$, $Date$
+ * @created Oct 11, 2007
+ * @since 1.0
+ */
+public class Jaiku implements Runnable
+{
+ /**
+ * The bot.
+ */
+ private final Mobibot _bot;
+
+ /**
+ * The Jaiku API key.
+ */
+ private final String _key;
+
+ /**
+ * The Jaiku user.
+ */
+ private final String _user;
+
+ /**
+ * The Jaiku message.
+ */
+ private final String _message;
+
+ /**
+ * The nick of the person who sent the message.
+ */
+ private final String _sender;
+
+ /**
+ * Creates a new Jaiku object.
+ *
+ * @param bot The bot.
+ * @param sender The nick of the person who sent the message.
+ * @param user The Jaiku user.
+ * @param key The Jaiku API key.
+ * @param message The Jaiku message.
+ */
+ public Jaiku(Mobibot bot, String sender, String user, String key, String message)
+ {
+ _bot = bot;
+ _user = user;
+ _key = key;
+ _message = message;
+ _sender = sender;
+ }
+
+ public final void run()
+ {
+ try
+ {
+ final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
+ config.setServerURL(new URL("http://api.jaiku.com/xmlrpc"));
+
+ final XmlRpcClient client = new XmlRpcClient();
+ client.setConfig(config);
+
+ final Map map = new HashMap(0);
+ map.put("user", _user);
+ map.put("personal_key", _key);
+ map.put("message", _bot.getChannel() + ' ' + _message + " (" + _sender + ')');
+
+ final List params = new ArrayList(0);
+ params.add(map);
+
+ client.execute("presence.send", params);
+ }
+ catch (Exception e)
+ {
+ _bot.getLogger().warn("Unable to post to Jaiku: " + _message, e);
+ _bot.send(_sender, "An error has occurred: " + e.getMessage());
+ }
+ }
+}
diff --git a/src/net/thauvin/erik/mobibot/Mobibot.java b/src/net/thauvin/erik/mobibot/Mobibot.java
index 35d74ca..2190f0f 100644
--- a/src/net/thauvin/erik/mobibot/Mobibot.java
+++ b/src/net/thauvin/erik/mobibot/Mobibot.java
@@ -37,43 +37,34 @@
package net.thauvin.erik.mobibot;
import com.primalworld.math.MathEvaluator;
-
import com.sun.syndication.feed.synd.*;
import com.sun.syndication.fetcher.impl.FeedFetcherCache;
import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.SyndFeedOutput;
-
import org.apache.commons.cli.*;
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.commons.net.WhoisClient;
-
import org.apache.log4j.Level;
-
import org.jibble.pircbot.Colors;
import org.jibble.pircbot.PircBot;
import org.jibble.pircbot.User;
import java.io.*;
-
import java.net.InetAddress;
import java.net.UnknownHostException;
-
import java.nio.channels.FileChannel;
-
import java.text.SimpleDateFormat;
-
import java.util.*;
-
/**
* Implements the #mobitopia bot.
*
- * @author Erik C. Thauvin
+ * @author Erik C. Thauvin
* @version $Revision$, $Date$
* @created Jan 31, 2004
- * @since 1.0
+ * @since 1.0
*/
public class Mobibot extends PircBot
{
@@ -85,11 +76,10 @@ public class Mobibot extends PircBot
/**
* The info strings.
*/
- private static final String[] INFO_STRS =
- {
- "Mobibot v" + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber() +
- " by Erik C. Thauvin (erik@thauvin.net)", "http://www.mobitopia.org/mobibot/"
- };
+ private static final String[] INFO_STRS = {"Mobibot v" + ReleaseInfo.getVersion() + '.'
+ + ReleaseInfo.getBuildNumber()
+ + " by Erik C. Thauvin (erik@thauvin.net)",
+ "http://www.mobitopia.org/mobibot/"};
/**
* Debug command line argument.
@@ -196,6 +186,10 @@ public class Mobibot extends PircBot
*/
private static final String GOOGLE_CMD = "google";
+ /**
+ * The Jaiku command.
+ */
+ private static final String JAIKU_CMD = "jaiku";
/**
* The math command.
*/
@@ -275,7 +269,7 @@ public class Mobibot extends PircBot
* The date/time format for the {@link #TIME_CMD time} command.
*/
private static final SimpleDateFormat TIME_SDF =
- new SimpleDateFormat("'The time is 'HH:mm' on 'EEE, d MMM yyyy' in '");
+ new SimpleDateFormat("'The time is 'HH:mm' on 'EEE, d MMM yyyy' in '");
/**
* The beats (Internet Time) keyword.
@@ -443,6 +437,16 @@ public class Mobibot extends PircBot
private String _googleKey = "";
+ /**
+ * The Jaiku API key.
+ */
+ private String _jaikuKey = "";
+
+ /**
+ * The Jaiku user.
+ */
+ private String _jaikuUser = "";
+
/**
* The history/backlogs array.
*/
@@ -453,7 +457,6 @@ public class Mobibot extends PircBot
*/
private String _identMsg = "";
-
/**
* The ident nick.
*/
@@ -504,12 +507,11 @@ public class Mobibot extends PircBot
*/
private String _weblogURL = "";
-
/**
* Creates a new Mobibot object.
*
- * @param server The server.
- * @param port The port.
+ * @param server The server.
+ * @param port The port.
* @param channel The channel.
* @param logsDir The logs directory.
*/
@@ -565,7 +567,7 @@ public class Mobibot extends PircBot
/**
* Returns true if the given string is valid.
*
- * @param s The string to validate.
+ * @param s The string to validate.
*
* @return true if the string is non-empty and not null, false otherwise.
*/
@@ -577,7 +579,7 @@ public class Mobibot extends PircBot
/**
* The Truth Is Out There...
*
- * @param args The command line arguments.
+ * @param args The command line arguments.
*
* @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE
*/
@@ -586,10 +588,12 @@ public class Mobibot extends PircBot
// Setup the command line options
final Options options = new Options();
options.addOption(HELP_ARG.substring(0, 1), HELP_ARG, false, "print this help message");
- options.addOption(DEBUG_ARG.substring(0, 1), DEBUG_ARG, false,
- "print debug & logging data directly to the console");
+ options.addOption(DEBUG_ARG.substring(0, 1),
+ DEBUG_ARG,
+ false,
+ "print debug & logging data directly to the console");
options.addOption(OptionBuilder.withArgName("file").hasArg().withDescription("use alternate properties file")
- .withLongOpt(PROPS_ARG).create(PROPS_ARG.substring(0, 1)));
+ .withLongOpt(PROPS_ARG).create(PROPS_ARG.substring(0, 1)));
// Parse the command line
final CommandLineParser parser = new PosixParser();
@@ -664,9 +668,8 @@ public class Mobibot extends PircBot
try
{
- stdout =
- new PrintStream(new FileOutputStream(logsDir + channel.substring(1) + '.' + today() + ".log",
- true));
+ stdout = new PrintStream(new FileOutputStream(
+ logsDir + channel.substring(1) + '.' + today() + ".log", true));
}
catch (IOException e)
{
@@ -692,7 +695,6 @@ public class Mobibot extends PircBot
System.setErr(stderr);
}
-
// Get the bot's properties
final String login = p.getProperty("login", nickname);
final String weblogURL = p.getProperty("weblog", "");
@@ -709,6 +711,10 @@ public class Mobibot extends PircBot
final String dname = p.getProperty("delicious-user");
final String dpwd = p.getProperty("delicious-pwd");
+ // Get the Jaiku properties
+ final String jname = p.getProperty("jaiku-user");
+ final String jkey = p.getProperty("jaiku-key");
+
// Create the bot
final Mobibot bot = new Mobibot(server, port, channel, logsDir);
@@ -735,13 +741,18 @@ public class Mobibot extends PircBot
// Set the Google key
bot.setGoogleKey(googleKey);
-
if (isValidString(dname) && isValidString(dpwd))
{
// Set the del.icio.us authentication
bot.setDeliciousAuth(dname, dpwd);
}
+ if (isValidString(jname) && isValidString(jkey))
+ {
+ // Set the Jaiku authentication
+ bot.setJaikuAuth(jname, jkey);
+ }
+
// Set the tags
bot.setTags(tags);
@@ -772,8 +783,8 @@ public class Mobibot extends PircBot
{
if (retries == MAX_RECONNECT)
{
- System.err.println("Unable to connect to " + server + " after " + MAX_RECONNECT +
- " retries.");
+ System.err.println(
+ "Unable to connect to " + server + " after " + MAX_RECONNECT + " retries.");
e.printStackTrace(System.err);
System.exit(1);
}
@@ -799,11 +810,10 @@ public class Mobibot extends PircBot
}
}
-
/**
* Converts XML/XHTML entities to plain text.
*
- * @param str The string to unescape.
+ * @param str The string to unescape.
*
* @return The unescaped string.
*/
@@ -833,7 +843,7 @@ public class Mobibot extends PircBot
* Sends an action to the channel.
*
* @param channel The channel.
- * @param action The action.
+ * @param action The action.
*/
public final void action(String channel, String action)
{
@@ -877,7 +887,7 @@ public class Mobibot extends PircBot
* Responds with the bot's help.
*
* @param sender The nick of the person who sent the private message.
- * @param topic The help topic, if any.
+ * @param topic The help topic, if any.
*/
public final void helpResponse(String sender, String topic)
{
@@ -919,6 +929,11 @@ public class Mobibot extends PircBot
send(sender, "To search Google:");
send(sender, DOUBLE_INDENT + bold(getNick() + ": " + GOOGLE_CMD + " "));
}
+ else if (lcTopic.endsWith(JAIKU_CMD))
+ {
+ send(sender, "To post to Jaiku:");
+ send(sender, DOUBLE_INDENT + bold(getNick() + ": " + JAIKU_CMD + " "));
+ }
else if (lcTopic.endsWith(RECAP_CMD))
{
send(sender, "To list the last 10 public channel messages:");
@@ -1030,15 +1045,16 @@ public class Mobibot extends PircBot
send(sender, "For more information on specific command, type:");
send(sender, DOUBLE_INDENT + bold(getNick() + ": " + HELP_CMD + " "));
send(sender, "The commands are:");
- send(sender, DOUBLE_INDENT +
- bold(CALC_CMD + ' ' + CURRENCY_CMD + ' ' + DICE_CMD + ' ' + GOOGLE_CMD + ' ' + IGNORE_CMD));
- send(sender, DOUBLE_INDENT +
- bold(INFO_CMD + ' ' + getChannel().substring(1) + ' ' + LOOKUP_CMD + ' ' + HELP_POSTING_KEYWORD + ' ' +
- RECAP_CMD));
- send(sender, DOUBLE_INDENT +
- bold(SPELL_CMD + ' ' + STOCK_CMD + ' ' + HELP_TAGS_KEYWORD + ' ' + TIME_CMD + ' ' + USERS_CMD + ' ' +
- VIEW_CMD));
- send(sender, DOUBLE_INDENT + bold(WEATHER_CMD));
+ send(sender,
+ DOUBLE_INDENT + bold(
+ CALC_CMD + ' ' + CURRENCY_CMD + ' ' + DICE_CMD + ' ' + GOOGLE_CMD + ' ' + IGNORE_CMD));
+ send(sender,
+ DOUBLE_INDENT + bold(INFO_CMD + ' ' + getChannel().substring(1) + ' ' + LOOKUP_CMD + ' '
+ + HELP_POSTING_KEYWORD + ' ' + RECAP_CMD));
+ send(sender,
+ DOUBLE_INDENT + bold(SPELL_CMD + ' ' + STOCK_CMD + ' ' + HELP_TAGS_KEYWORD + ' ' + TIME_CMD + ' '
+ + USERS_CMD + ' ' + VIEW_CMD));
+ send(sender, DOUBLE_INDENT + bold(JAIKU_CMD + ' ' + WEATHER_CMD));
if (isOp(sender))
{
@@ -1051,7 +1067,7 @@ public class Mobibot extends PircBot
/**
* Sends a private notice.
*
- * @param sender The nick of the person who sent the message.
+ * @param sender The nick of the person who sent the message.
* @param message The actual message.
*/
public final void send(String sender, String message)
@@ -1062,8 +1078,8 @@ public class Mobibot extends PircBot
/**
* Sends a private message or notice.
*
- * @param sender The nick of the person who sent the message.
- * @param message The actual message.
+ * @param sender The nick of the person who sent the message.
+ * @param message The actual message.
* @param isPrivate Set to true if the response should be a private message, otherwise a notice is sent.
*/
public final void send(String sender, String message, boolean isPrivate)
@@ -1094,11 +1110,11 @@ public class Mobibot extends PircBot
/**
* This method is called whenever an ACTION is sent from a user.
*
- * @param sender The nick of the person who sent the action.
- * @param login The login of the person who sent the action.
+ * @param sender The nick of the person who sent the action.
+ * @param login The login of the person who sent the action.
* @param hostname The hostname of the person who sent the action.
- * @param target The target of the action, be it a channel or our nick.
- * @param action The action carried out by the user.
+ * @param target The target of the action, be it a channel or our nick.
+ * @param action The action carried out by the user.
*/
protected final void onAction(String sender, String login, String hostname, String target, String action)
{
@@ -1145,8 +1161,9 @@ public class Mobibot extends PircBot
{
if (_logger.isDebugEnabled())
{
- _logger.debug("Unable to reconnect to " + _ircServer + " after " + MAX_RECONNECT +
- " retries.", ex);
+ _logger.debug(
+ "Unable to reconnect to " + _ircServer + " after " + MAX_RECONNECT + " retries.",
+ ex);
}
e.printStackTrace(System.err);
@@ -1174,11 +1191,11 @@ public class Mobibot extends PircBot
/**
* This method is called whenever a message is sent to a channel.
*
- * @param channel The channel to which the message was sent.
- * @param sender The nick of the person who sent the message.
- * @param login The login of the person who sent the message.
+ * @param channel The channel to which the message was sent.
+ * @param sender The nick of the person who sent the message.
+ * @param login The login of the person who sent the message.
* @param hostname The hostname of the person who sent the message.
- * @param message The actual message sent.
+ * @param message The actual message sent.
*/
protected final void onMessage(String channel, String sender, String login, String hostname, String message)
{
@@ -1222,9 +1239,13 @@ public class Mobibot extends PircBot
if (tagSep != -1)
{
- _entries.add(new EntryLink(cmd, title.substring(0, tagSep), sender, login, channel,
- (_defaultTags + ' ' +
- title.substring(tagSep + TAGS_MARKER.length()))));
+ _entries.add(new EntryLink(cmd,
+ title.substring(0, tagSep),
+ sender,
+ login,
+ channel,
+ (_defaultTags + ' ' + title
+ .substring(tagSep + TAGS_MARKER.length()))));
}
else
{
@@ -1287,14 +1308,18 @@ public class Mobibot extends PircBot
}
else if (cmd.equals(PING_CMD))
{
- final String[] pings =
- {
- "is barely alive.", "is trying to stay awake.", "has gone fishing.",
- "is somewhere over the rainbow.", "has fallen and can't get up.",
- "is running. You better go chase it.", "has just spontantiously combusted.",
- "is talking to itself... don't interrupt. That's rude.", "is bartending at an AA meeting.",
- "is hibernating.", "is saving energy: apathetic mode activated.", "is busy. Go away!"
- };
+ final String[] pings = {"is barely alive.",
+ "is trying to stay awake.",
+ "has gone fishing.",
+ "is somewhere over the rainbow.",
+ "has fallen and can't get up.",
+ "is running. You better go chase it.",
+ "has just spontantiously combusted.",
+ "is talking to itself... don't interrupt. That's rude.",
+ "is bartending at an AA meeting.",
+ "is hibernating.",
+ "is saving energy: apathetic mode activated.",
+ "is busy. Go away!"};
final Random r = new Random();
@@ -1362,6 +1387,10 @@ public class Mobibot extends PircBot
{
googleResponse(sender, args);
}
+ else if (cmd.startsWith(JAIKU_CMD))
+ {
+ jaikuResponse(sender, args);
+ }
else if (cmd.startsWith(SPELL_CMD))
{
spellResponse(sender, args);
@@ -1704,10 +1733,10 @@ public class Mobibot extends PircBot
/**
* This method is called whenever a private message is sent to the bot.
*
- * @param sender The nick of the person who sent the private message.
- * @param login The login of the person who sent the private message.
- * @param hostname The hostname of the person who sent the private message.
- * @param message The actual message sent.
+ * @param sender The nick of the person who sent the private message.
+ * @param login The login of the person who sent the private message.
+ * @param hostname The hostname of the person who sent the private message.
+ * @param message The actual message sent.
*
* @noinspection UseOfSystemOutOrSystemErr
*/
@@ -1874,7 +1903,7 @@ public class Mobibot extends PircBot
/**
* Makes the given string bold.
*
- * @param s The string.
+ * @param s The string.
*
* @return The bold string.
*/
@@ -1886,27 +1915,27 @@ public class Mobibot extends PircBot
/**
* Builds an entry's comment for display on the channel.
*
- * @param entryIndex The entry's index.
- * @param commentIndex The comment's index.
- * @param comment The {@link EntryComment comment} object.
+ * @param entryIndex The entry's index.
+ * @param commentIndex The comment's index.
+ * @param comment The {@link EntryComment comment} object.
*
* @return The entry's comment.
*/
private static String buildComment(int entryIndex, int commentIndex, EntryComment comment)
{
- return (LINK_CMD + (entryIndex + 1) + '.' + (commentIndex + 1) + ": [" + comment.getNick() + "] " +
- comment.getComment());
+ return (LINK_CMD + (entryIndex + 1) + '.' + (commentIndex + 1) + ": [" + comment.getNick() + "] " + comment
+ .getComment());
}
/**
* Builds an entry's link for display on the channel.
*
- * @param index The entry's index.
- * @param entry The {@link EntryLink entry} object.
+ * @param index The entry's index.
+ * @param entry The {@link EntryLink entry} object.
*
* @return The entry's link.
*
- * @see #buildLink(int, EntryLink, boolean)
+ * @see #buildLink(int,EntryLink,boolean)
*/
private static String buildLink(int index, EntryLink entry)
{
@@ -1916,9 +1945,9 @@ public class Mobibot extends PircBot
/**
* Builds an entry's link for display on the channel.
*
- * @param index The entry's index.
- * @param entry The {@link EntryLink entry} object.
- * @param isView Set to true to display the number of comments.
+ * @param index The entry's index.
+ * @param entry The {@link EntryLink entry} object.
+ * @param isView Set to true to display the number of comments.
*
* @return The entry's link.
*/
@@ -1952,8 +1981,8 @@ public class Mobibot extends PircBot
/**
* Build an entry's tags/categories for diplay on the channel.
*
- * @param entryIndex The entry's index.
- * @param entry The {@link EntryLink entry} object.
+ * @param entryIndex The entry's index.
+ * @param entry The {@link EntryLink entry} object.
*
* @return The entry's tags.
*/
@@ -1965,13 +1994,13 @@ public class Mobibot extends PircBot
/**
* Copies a file.
*
- * @param in The source file.
- * @param out The destination file.
+ * @param in The source file.
+ * @param out The destination file.
*
* @throws IOException If the file could not be copied.
*/
private static void copyFile(File in, File out)
- throws IOException
+ throws IOException
{
FileChannel inChannel = null;
FileChannel outChannel = null;
@@ -2029,8 +2058,8 @@ public class Mobibot extends PircBot
/**
* Ensures that the given location (File/URL) has a trailing slash (/) to indicate a directory.
*
- * @param location The File or URL location.
- * @param isUrl Set to true if the location is a URL
+ * @param location The File or URL location.
+ * @param isUrl Set to true if the location is a URL
*
* @return The location ending with a slash.
*/
@@ -2063,8 +2092,8 @@ public class Mobibot extends PircBot
/**
* Returns the port.
*
- * @param property The port property value.
- * @param defaultValue The default value.
+ * @param property The port property value.
+ * @param defaultValue The default value.
*
* @return The port or default value if invalid.
*/
@@ -2127,14 +2156,14 @@ public class Mobibot extends PircBot
/**
* Performs a DNS lookup on the specified query.
*
- * @param query The IP address or hostname.
+ * @param query The IP address or hostname.
*
- * @return The lookup query result string.
+ * @return The lookup query result string.
*
- * @exception UnknownHostException If the host is unknown.
+ * @throws UnknownHostException If the host is unknown.
*/
private static String lookup(String query)
- throws UnknownHostException
+ throws UnknownHostException
{
final StringBuffer buffer = new StringBuffer("");
@@ -2168,18 +2197,17 @@ public class Mobibot extends PircBot
return buffer.toString();
}
-
/**
* Stores the last 10 public messages and actions.
*
- * @param sender The nick of the person who sent the private message.
- * @param message The actual message sent.
+ * @param sender The nick of the person who sent the private message.
+ * @param message The actual message sent.
* @param isAction Set to true if the message is an action.
*/
private static void recap(String sender, String message, boolean isAction)
{
- RECAP_ARRAY.add(HHMM_SDF.format(Calendar.getInstance().getTime()) + " -> " + sender + (isAction ? " " : ": ") +
- message);
+ RECAP_ARRAY.add(HHMM_SDF.format(Calendar.getInstance().getTime()) + " -> " + sender + (isAction ? " " : ": ")
+ + message);
if (RECAP_ARRAY.size() > MAX_RECAP)
{
@@ -2217,14 +2245,14 @@ public class Mobibot extends PircBot
/**
* Performs a whois IP query.
*
- * @param query The IP address.
+ * @param query The IP address.
*
* @return The IP whois data, if any.
*
* @throws IOException If a connection error occurs.
*/
private static String[] whois(String query)
- throws IOException
+ throws IOException
{
final WhoisClient whois = new WhoisClient();
String[] lines;
@@ -2266,7 +2294,7 @@ public class Mobibot extends PircBot
/**
* Returns the index of the specified duplicate entry, if any.
*
- * @param link The link.
+ * @param link The link.
*
* @return The index or -1 if none.
*/
@@ -2304,7 +2332,8 @@ public class Mobibot extends PircBot
if (Character.isLetter(c))
{
- buff.append('[').append(String.valueOf(c).toLowerCase()).append(String.valueOf(c).toUpperCase()).append(']');
+ buff.append('[').append(String.valueOf(c).toLowerCase()).append(String.valueOf(c).toUpperCase())
+ .append(']');
}
else
{
@@ -2329,7 +2358,7 @@ public class Mobibot extends PircBot
* Responds with the Google search results for the specified query.
*
* @param sender The nick of the person who sent the private message.
- * @param query The Google query to execute.
+ * @param query The Google query to execute.
*/
private void googleResponse(String sender, String query)
{
@@ -2350,10 +2379,35 @@ public class Mobibot extends PircBot
}
}
+ /**
+ * Posts a message to Jaiku.
+ *
+ * @param sender The sender's nick.
+ * @param message The message.
+ */
+ private void jaikuResponse(String sender, String message)
+ {
+ if (isValidString(_jaikuKey) && isValidString(_jaikuUser))
+ {
+ if (message.length() > 0)
+ {
+ new Thread(new Jaiku(this, sender, _jaikuUser, _jaikuKey, message)).start();
+ }
+ else
+ {
+ helpResponse(sender, JAIKU_CMD);
+ }
+ }
+ else
+ {
+ send(sender, "The Jaiku posting facility is disabled.");
+ }
+ }
+
/**
* Responds with the bot's information.
*
- * @param sender The nick of the person who sent the message.
+ * @param sender The nick of the person who sent the message.
* @param isPrivate Set to true is the response should be send as a private message.
*/
private void infoResponse(String sender, boolean isPrivate)
@@ -2372,14 +2426,16 @@ public class Mobibot extends PircBot
timeInSeconds -= (hours * 3600L);
final long minutes = timeInSeconds / 60L;
- send(sender, "Uptime: " + days + " day(s) " + hours + " hour(s) " + minutes + " minute(s) [Entries: " +
- _entries.size() + ']', isPrivate);
+ send(sender,
+ "Uptime: " + days + " day(s) " + hours + " hour(s) " + minutes + " minute(s) [Entries: " + _entries.size()
+ + ']',
+ isPrivate);
}
/**
* Determines whether the specified nick should be ignored.
*
- * @param nick The nick.
+ * @param nick The nick.
*
* @return true if the nick should be ignored, false otherwise.
*/
@@ -2396,7 +2452,7 @@ public class Mobibot extends PircBot
/**
* Returns true is the specified sender is an Op on the {@link #_channel channel}.
*
- * @param sender The sender.
+ * @param sender The sender.
*
* @return true, if the sender is an Op.
*/
@@ -2422,13 +2478,13 @@ public class Mobibot extends PircBot
/**
* Loads the backlogs.
*
- * @param file The file containing the backlogs.
+ * @param file The file containing the backlogs.
*
* @throws FileNotFoundException If the file was not found.
- * @throws FeedException If an error occurred while reading the feed.
+ * @throws FeedException If an error occurred while reading the feed.
*/
private void loadBacklogs(String file)
- throws FileNotFoundException, FeedException
+ throws FileNotFoundException, FeedException
{
_history.clear();
@@ -2471,13 +2527,13 @@ public class Mobibot extends PircBot
/**
* Loads the current entries.
*
- * @param file The file containing the current entries.
+ * @param file The file containing the current entries.
*
* @throws FileNotFoundException If the file was not found.
- * @throws FeedException If an error occurred while reading the feed.
+ * @throws FeedException If an error occurred while reading the feed.
*/
private void loadEntries(String file)
- throws FileNotFoundException, FeedException
+ throws FileNotFoundException, FeedException
{
_entries.clear();
@@ -2504,11 +2560,14 @@ public class Mobibot extends PircBot
for (int i = items.size() - 1; i >= 0; i--)
{
item = (SyndEntryImpl) items.get(i);
- author =
- item.getAuthor().substring(item.getAuthor().lastIndexOf('(') + 1, item.getAuthor().length() - 1);
- entry =
- new EntryLink(item.getLink(), item.getTitle(), author, getChannel(), item.getPublishedDate(),
- item.getCategories());
+ author = item.getAuthor()
+ .substring(item.getAuthor().lastIndexOf('(') + 1, item.getAuthor().length() - 1);
+ entry = new EntryLink(item.getLink(),
+ item.getTitle(),
+ author,
+ getChannel(),
+ item.getPublishedDate(),
+ item.getCategories());
description = item.getDescription();
comments = description.getValue().split(" ");
@@ -2545,7 +2604,7 @@ public class Mobibot extends PircBot
* Responds with the results of a DNS query.
*
* @param sender The nick of the person who sent the message
- * @param query The hostname or IP address.
+ * @param query The hostname or IP address.
*/
private void lookupResponse(String sender, String query)
{
@@ -2557,7 +2616,8 @@ public class Mobibot extends PircBot
}
catch (UnknownHostException e)
{
- if (query.matches("(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"))
+ if (query.matches(
+ "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"))
{
try
{
@@ -2607,7 +2667,7 @@ public class Mobibot extends PircBot
/**
* Responds with the last 10 public messages.
*
- * @param sender The nick of the person who sent the private message.
+ * @param sender The nick of the person who sent the private message.
* @param isPrivate Set to true is the response should be send as a private message.
*/
private void recapResponse(String sender, boolean isPrivate)
@@ -2821,6 +2881,18 @@ public class Mobibot extends PircBot
_googleKey = googleKey;
}
+ /**
+ * Sets the Jaiku user and API key..
+ *
+ * @param user The Jaiku user.
+ * @param key The Jaiku API key.
+ */
+ private void setJaikuAuth(String user, String key)
+ {
+ _jaikuKey = key;
+ _jaikuUser = user;
+ }
+
/**
* Sets the ident password.
*
@@ -2831,7 +2903,6 @@ public class Mobibot extends PircBot
_ident = pwd;
}
-
/**
* Sets the ident message.
*
@@ -2842,7 +2913,6 @@ public class Mobibot extends PircBot
_identMsg = msg;
}
-
/**
* Sets the ident nickname.
*
@@ -2905,7 +2975,7 @@ public class Mobibot extends PircBot
* Uses Google to correctly spell a sentence.
*
* @param sender The nick of the person who sent the message
- * @param spell The sentence to spell.
+ * @param spell The sentence to spell.
*/
private void spellResponse(String sender, String spell)
{
@@ -2947,8 +3017,8 @@ public class Mobibot extends PircBot
/**
* Responds with the current time.
*
- * @param sender The nick of the person who sent the message.
- * @param args The time command arguments.
+ * @param sender The nick of the person who sent the message.
+ * @param args The time command arguments.
* @param isPrivate Set to true is the response should be send as a private message.
*/
private void timeResponse(String sender, String args, boolean isPrivate)
@@ -2966,9 +3036,8 @@ public class Mobibot extends PircBot
else
{
TIME_SDF.setTimeZone(TimeZone.getTimeZone(tz));
- response =
- TIME_SDF.format(Calendar.getInstance().getTime()) +
- tz.substring(tz.indexOf('/') + 1).replace('_', ' ');
+ response = TIME_SDF.format(Calendar.getInstance().getTime()) + tz.substring(tz.indexOf('/') + 1)
+ .replace('_', ' ');
}
}
else
@@ -2997,7 +3066,7 @@ public class Mobibot extends PircBot
/**
* Responds with the users on a channel.
*
- * @param sender The nick of the person who sent the message.
+ * @param sender The nick of the person who sent the message.
* @param isPrivate Set to true is the response should be send as a private message.
*/
private void usersResponse(String sender, boolean isPrivate)
@@ -3025,8 +3094,8 @@ public class Mobibot extends PircBot
/**
* Responds with the stored links.
*
- * @param sender The nick of the person who sent the message.
- * @param args The view command arguments.
+ * @param sender The nick of the person who sent the message.
+ * @param args The view command arguments.
* @param isPrivate Set to true is the response should be send as a private message.
*/
private void viewResponse(String sender, String args, boolean isPrivate)
@@ -3085,14 +3154,16 @@ public class Mobibot extends PircBot
if (lcArgs.length() > 0)
{
- if ((entry.getLink().toLowerCase().indexOf(lcArgs) != -1) ||
- (entry.getTitle().toLowerCase().indexOf(lcArgs) != -1) ||
- (entry.getNick().toLowerCase().indexOf(lcArgs) != -1))
+ if ((entry.getLink().toLowerCase().indexOf(lcArgs) != -1)
+ || (entry.getTitle().toLowerCase().indexOf(lcArgs) != -1) || (
+ entry.getNick().toLowerCase().indexOf(lcArgs) != -1))
{
if (sent > MAX_ENTRIES)
{
- send(sender, "To view more, try: " +
- bold(getNick() + ": " + VIEW_CMD + ' ' + (i + 1) + ' ' + lcArgs), isPrivate);
+ send(sender,
+ "To view more, try: " + bold(
+ getNick() + ": " + VIEW_CMD + ' ' + (i + 1) + ' ' + lcArgs),
+ isPrivate);
break;
}
@@ -3105,8 +3176,9 @@ public class Mobibot extends PircBot
{
if (sent > MAX_ENTRIES)
{
- send(sender, "To view more, try: " + bold(getNick() + ": " + VIEW_CMD + ' ' + (i + 1)),
- isPrivate);
+ send(sender,
+ "To view more, try: " + bold(getNick() + ": " + VIEW_CMD + ' ' + (i + 1)),
+ isPrivate);
break;
}
@@ -3125,8 +3197,8 @@ public class Mobibot extends PircBot
/**
* Responds with weather from the specified station ID.
*
- * @param sender The nick of the person who sent the message.
- * @param id The station's ID.
+ * @param sender The nick of the person who sent the message.
+ * @param id The station's ID.
* @param isPrivate Set to true is the response should be send as a private message.
*/
private void weatherResponse(String sender, String id, boolean isPrivate)
diff --git a/src/net/thauvin/erik/mobibot/ReleaseInfo.java b/src/net/thauvin/erik/mobibot/ReleaseInfo.java
index f764f64..9f0f51e 100644
--- a/src/net/thauvin/erik/mobibot/ReleaseInfo.java
+++ b/src/net/thauvin/erik/mobibot/ReleaseInfo.java
@@ -1,5 +1,5 @@
/* Created by JReleaseInfo AntTask from Open Source Competence Group */
-/* Creation date Wed Jul 18 23:09:10 PDT 2007 */
+/* Creation date Thu Oct 11 16:35:17 PDT 2007 */
package net.thauvin.erik.mobibot;
import java.util.Date;
@@ -20,21 +20,21 @@ public class ReleaseInfo {
}
- /** buildDate (set during build process to 1184825350594L). */
- private static final Date buildDate = new Date(1184825350594L);
+ /** buildDate (set during build process to 1192145717288L). */
+ private static final Date buildDate = new Date(1192145717288L);
/**
- * Get buildDate (set during build process to Wed Jul 18 23:09:10 PDT 2007).
+ * Get buildDate (set during build process to Thu Oct 11 16:35:17 PDT 2007).
* @return Date buildDate
*/
public static Date getBuildDate() { return buildDate; }
/**
- * Get buildNumber (set during build process to 70).
+ * Get buildNumber (set during build process to 72).
* @return int buildNumber
*/
- public static int getBuildNumber() { return 70; }
+ public static int getBuildNumber() { return 72; }
/** project (set during build process to "mobibot"). */