diff --git a/buildnum.properties b/buildnum.properties
index 27edab5..18863df 100644
--- a/buildnum.properties
+++ b/buildnum.properties
@@ -1,3 +1,3 @@
#ANT Task: ch.oscg.jreleaseinfo.BuildNumberHandler
-#Sun Mar 06 13:05:37 PST 2005
-build.num.last=3
+#Thu May 05 12:13:40 PDT 2005
+build.num.last=26
diff --git a/mobibot.fb b/mobibot.fb
index f02b78c..3a6314f 100644
--- a/mobibot.fb
+++ b/mobibot.fb
@@ -3,18 +3,19 @@ D:\projects\java\mobibot\build
[Source dirs]
D:\projects\java\mobibot\src
[Aux classpath entries]
-D:\projects\java\mobibot\lib\commons-httpclient-2.0-final.jar
+D:\projects\java\mobibot\lib\commons-cli-1.0.jar
+D:\projects\java\mobibot\lib\commons-codec-1.3.jar
+D:\projects\java\mobibot\lib\commons-httpclient-3.0-rc1.jar
D:\projects\java\mobibot\lib\commons-logging.jar
-D:\projects\java\mobibot\lib\commons-net-1.1.0.jar
-D:\projects\java\mobibot\lib\EXML.jar
-D:\projects\java\mobibot\lib\fetchrss.jar
+D:\projects\java\mobibot\lib\commons-net-1.2.2.jar
+D:\projects\java\mobibot\lib\delicious-1.5.jar
D:\projects\java\mobibot\lib\google.jar
D:\projects\java\mobibot\lib\googleapi.jar
-D:\projects\java\mobibot\lib\jakarta-oro-2.0.7.jar
D:\projects\java\mobibot\lib\jakarta-oro-2.0.8.jar
-D:\projects\java\mobibot\lib\jdom.jar
-D:\projects\java\mobibot\lib\jweather-0.2.3.jar
+D:\projects\java\mobibot\lib\jdom-1.0.jar
+D:\projects\java\mobibot\lib\jweather-0.2.5.jar
D:\projects\java\mobibot\lib\log4j-1.2.8.jar
D:\projects\java\mobibot\lib\MathEvaluator.jar
D:\projects\java\mobibot\lib\pircbot.jar
-D:\projects\java\mobibot\lib\rsslibj.jar
+D:\projects\java\mobibot\lib\rome-0.4.jar
+D:\projects\java\mobibot\lib\rome-fetcher-0.4.jar
diff --git a/mobibot.ipr b/mobibot.ipr
index 61c321a..9d96bb8 100644
--- a/mobibot.ipr
+++ b/mobibot.ipr
@@ -44,7 +44,7 @@
-
+
diff --git a/mobibot.iws b/mobibot.iws
index a9fa231..f8d6f54 100644
--- a/mobibot.iws
+++ b/mobibot.iws
@@ -112,70 +112,61 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -204,21 +195,15 @@
-
-
-
+
+
+
-
-
-
-
-
-
-
+
@@ -262,8 +247,8 @@
-
+
@@ -341,7 +326,13 @@
+
+
+
+
+
+
@@ -396,27 +387,27 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
@@ -501,23 +492,16 @@
-
+
-
-
-
-
-
-
-
-
+
-
+
@@ -526,76 +510,81 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -609,7 +598,7 @@
-
+
diff --git a/src/net/thauvin/erik/mobibot/CurrencyConverter.java b/src/net/thauvin/erik/mobibot/CurrencyConverter.java
index f13ba84..745c1de 100644
--- a/src/net/thauvin/erik/mobibot/CurrencyConverter.java
+++ b/src/net/thauvin/erik/mobibot/CurrencyConverter.java
@@ -81,7 +81,7 @@ public class CurrencyConverter implements Runnable
/**
* The last exchange rates table publication date.
*/
- private static String s_date = "";
+ private String s_date = "";
/**
* The bot.
diff --git a/src/net/thauvin/erik/mobibot/DeliciousPoster.java b/src/net/thauvin/erik/mobibot/DeliciousPoster.java
index 08235a3..630bf1a 100644
--- a/src/net/thauvin/erik/mobibot/DeliciousPoster.java
+++ b/src/net/thauvin/erik/mobibot/DeliciousPoster.java
@@ -50,35 +50,34 @@ import del.icio.us.Delicious;
public class DeliciousPoster
{
private final Delicious _delicious;
- private final String _tags;
+ private final String _ircServer;
/**
* Creates a new DeliciousPoster instance.
*
- * @param username The del.icio.us username.
- * @param password The del.icio.us password.
- * @param tags The del.icio.us tags.
+ * @param username The del.icio.us username.
+ * @param password The del.icio.us password.
+ * @param ircServer The IRC server.
*/
- public DeliciousPoster(String username, String password, String tags)
+ public DeliciousPoster(String username, String password, String ircServer)
{
_delicious = new Delicious(username, password);
- _tags = tags;
+ _ircServer = ircServer;
}
/**
* Adds a post to del.icio.us.
*
- * @param entry The entry to add.
- * @param extended The del.icio.us extended data.
+ * @param entry The entry to add.
*/
- public final void addPost(final EntryLink entry, final String extended)
+ public final void addPost(final EntryLink entry)
{
final SwingWorker worker = new SwingWorker()
{
public Object construct()
{
- return new Boolean(_delicious.addPost(entry.getLink(), entry.getTitle(), extended, _tags,
- entry.getDate()));
+ return Boolean.valueOf(_delicious.addPost(entry.getLink(), entry.getTitle(), postedBy(entry),
+ entry.getDeliciousTags(), entry.getDate()));
}
};
@@ -86,20 +85,57 @@ public class DeliciousPoster
}
/**
- * Delets a post to del.icio.us.
+ * Deletes a post to del.icio.us.
*
* @param entry The entry to delete.
*/
- public final void deletePost(final EntryLink entry)
+ public final void deletePost(EntryLink entry)
{
+ final String link = entry.getLink();
+
final SwingWorker worker = new SwingWorker()
{
public Object construct()
{
- return new Boolean(_delicious.deletePost(entry.getLink()));
+ return Boolean.valueOf(_delicious.deletePost(link));
}
};
worker.start();
}
+
+ /**
+ * Updates a post to del.icio.us.
+ *
+ * @param oldUrl The old post URL.
+ * @param entry The entry to add.
+ */
+ public final void updatePost(final String oldUrl, final EntryLink entry)
+ {
+ final SwingWorker worker = new SwingWorker()
+ {
+ public Object construct()
+ {
+ _delicious.deletePost(oldUrl);
+
+ return Boolean.valueOf(_delicious.addPost(entry.getLink(), entry.getTitle(), postedBy(entry),
+ entry.getDeliciousTags(), entry.getDate()));
+ }
+ };
+
+ worker.start();
+ }
+
+
+ /**
+ * Returns he del.icio.us extended attribution line.
+ *
+ * @param entry The entry.
+ *
+ * @return The extended attribution line.
+ */
+ private String postedBy(EntryLink entry)
+ {
+ return "Posted by " + entry.getNick() + " on " + entry.getChannel() + " (" + _ircServer + ')';
+ }
}
diff --git a/src/net/thauvin/erik/mobibot/EntryLink.java b/src/net/thauvin/erik/mobibot/EntryLink.java
index 5f3620a..f4ea17b 100644
--- a/src/net/thauvin/erik/mobibot/EntryLink.java
+++ b/src/net/thauvin/erik/mobibot/EntryLink.java
@@ -36,22 +36,20 @@
*/
package net.thauvin.erik.mobibot;
+import com.sun.syndication.feed.synd.SyndCategoryImpl;
+
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
/**
* The class used to store link entries.
*
- * @author Erik C. Thauvin
+ * @author Erik C. Thauvin
* @version $Revision$, $Date$
- *
* @created Jan 31, 2004
- * @since 1.0
+ * @since 1.0
*/
public class EntryLink implements Serializable
{
@@ -60,51 +58,72 @@ public class EntryLink implements Serializable
*/
static final long serialVersionUID = 3676245542270899086L;
- /**
- * The creation date.
- */
+ // The channel
+ private String _channel = "";
+
+ // The link's comments
+ private final List _comments = new ArrayList(0);
+
+ // The creation date
private Date _date = Calendar.getInstance().getTime();
- /**
- * The comments.
- */
- private final List _comments = new ArrayList(0);
+ // The link's URL
private String _link = "";
+
+ // The author's login
private String _login = "";
+
+ // The author's nickname
private String _nick = "";
+
+ // The tags/categories
+ private final List _tags = new ArrayList(0);
+
+ // The link's title
private String _title = "";
-
/**
* Creates a new entry.
*
- * @param link The new entry's link.
- * @param title The new entry's title.
- * @param nick The nickname of the author of the link.
- * @param date The entry date.
+ * @param link The new entry's link.
+ * @param title The new entry's title.
+ * @param nick The nickname of the author of the link.
+ * @param login The login of the author of the link.
+ * @param channel The channel.
+ * @param tags The entry's tags/categories.
*/
- public EntryLink(String link, String title, String nick, Date date)
- {
- _link = link;
- _title = title;
- _nick = nick;
- _date = date;
- }
-
- /**
- * Creates a new entry.
- *
- * @param link The new entry's link.
- * @param title The new entry's title.
- * @param nick The nickname of the author of the link.
- * @param login The login of the author of the link.
- */
- public EntryLink(String link, String title, String nick, String login)
+ public EntryLink(String link, String title, String nick, String login, String channel, String tags)
{
_link = link;
_title = title;
_nick = nick;
_login = login;
+ _channel = channel;
+
+ setTags(tags);
+ }
+
+
+ /**
+ * Creates a new entry.
+ *
+ * @param link The new entry's link.
+ * @param title The new entry's title.
+ * @param nick The nickname of the author of the link.
+ * @param channel The channel.
+ * @param date The entry date.
+ * @param tags The entry's tags/categories.
+ */
+ public EntryLink(String link, String title, String nick, String channel, Date date, List tags)
+ {
+ _link = link;
+ _title = title;
+ _nick = nick;
+ _channel = channel;
+ _date = date;
+
+
+ setTags(tags);
}
/**
@@ -112,28 +131,51 @@ public class EntryLink implements Serializable
*/
protected EntryLink()
{
- ; // Required for serialization.
+ ; // Required for serialization.
}
/**
- * Sets a comment.
+ * Adds a new comment.
*
- * @param index The comment's index.
- * @param comment The actual comment.
- * @param nick The nickname of the author of the comment.
+ * @param comment The actual comment.
+ * @param nick The nickname of the author of the comment.
+ *
+ * @return The total number of comments for this entry.
*/
- public final synchronized void setComment(int index, String comment, String nick)
+ public final synchronized int addComment(String comment, String nick)
+ {
+ _comments.add(new EntryComment(comment, nick));
+
+ return (_comments.size() - 1);
+ }
+
+ /**
+ * Deletes a specific comment.
+ *
+ * @param index The index of the comment to delete.
+ */
+ public final synchronized void deleteComment(int index)
{
if (index < _comments.size())
{
- _comments.set(index, new EntryComment(comment, nick));
+ _comments.remove(index);
}
}
+ /**
+ * Returns the channel the link was posted on.
+ *
+ * @return The channel
+ */
+ public final synchronized String getChannel()
+ {
+ return _channel;
+ }
+
/**
* Returns a comment.
*
- * @param index The comment's index.
+ * @param index The comment's index.
*
* @return The specific comment.
*/
@@ -173,13 +215,25 @@ public class EntryLink implements Serializable
}
/**
- * Sets the comment's link.
+ * Returns the tags formatted for del.icio.us.
*
- * @param link The new link.
+ * @return The tags as a space-deliminted string.
*/
- public final synchronized void setLink(String link)
+ public final synchronized String getDeliciousTags()
{
- this._link = link;
+ final StringBuffer tags = new StringBuffer(0);
+
+ for (int i = 0; i < _tags.size(); i++)
+ {
+ if (i != 0)
+ {
+ tags.append(' ');
+ }
+
+ tags.append(((SyndCategoryImpl) _tags.get(i)).getName());
+ }
+
+ return tags.toString();
}
/**
@@ -192,16 +246,6 @@ public class EntryLink implements Serializable
return _link;
}
- /**
- * Set the comment's author login.
- *
- * @param login The new login.
- */
- public final synchronized void setLogin(String login)
- {
- this._login = login;
- }
-
/**
* Return's the comment's author login.
*
@@ -212,16 +256,6 @@ public class EntryLink implements Serializable
return _login;
}
- /**
- * Sets the comment's author nickname.
- *
- * @param nick The new nickname.
- */
- public final synchronized void setNick(String nick)
- {
- this._nick = nick;
- }
-
/**
* Returns the comment's author nickname.
*
@@ -233,13 +267,13 @@ public class EntryLink implements Serializable
}
/**
- * Sets the comment's title.
+ * Returns the tags.
*
- * @param title The new title.
+ * @return The tags.
*/
- public final synchronized void setTitle(String title)
+ public final synchronized List getTags()
{
- this._title = title;
+ return _tags;
}
/**
@@ -252,34 +286,6 @@ public class EntryLink implements Serializable
return _title;
}
- /**
- * Adds a new comment.
- *
- * @param comment The actual comment.
- * @param nick The nickname of the author of the comment.
- *
- * @return The total number of comments for this entry.
- */
- public final synchronized int addComment(String comment, String nick)
- {
- _comments.add(new EntryComment(comment, nick));
-
- return (_comments.size() - 1);
- }
-
- /**
- * Deletes a specific comment.
- *
- * @param index The index of the comment to delete.
- */
- public final synchronized void deleteComment(int index)
- {
- if (index < _comments.size())
- {
- _comments.remove(index);
- }
- }
-
/**
* Returns true if the entry has comments.
*
@@ -287,6 +293,146 @@ public class EntryLink implements Serializable
*/
public final synchronized boolean hasComments()
{
- return (_comments.size() > 0);
+ return (!_comments.isEmpty());
+ }
+
+ /**
+ * Returns true if the entry has tags.
+ *
+ * @return true if there are tags, false otherwise.
+ */
+ public final synchronized boolean hasTags()
+ {
+ return (!_tags.isEmpty());
+ }
+
+ /**
+ * Sets the channel.
+ *
+ * @param channel The channel.
+ */
+ public final synchronized void setChannel(String channel)
+ {
+ _channel = channel;
+ }
+
+ /**
+ * /** Sets a comment.
+ *
+ * @param index The comment's index.
+ * @param comment The actual comment.
+ * @param nick The nickname of the author of the comment.
+ */
+ public final synchronized void setComment(int index, String comment, String nick)
+ {
+ if (index < _comments.size())
+ {
+ _comments.set(index, new EntryComment(comment, nick));
+ }
+ }
+
+ /**
+ * Sets the comment's link.
+ *
+ * @param link The new link.
+ */
+ public final synchronized void setLink(String link)
+ {
+ _link = link;
+ }
+
+ /**
+ * Set the comment's author login.
+ *
+ * @param login The new login.
+ */
+ public final synchronized void setLogin(String login)
+ {
+ _login = login;
+ }
+
+ /**
+ * Sets the comment's author nickname.
+ *
+ * @param nick The new nickname.
+ */
+ public final synchronized void setNick(String nick)
+ {
+ _nick = nick;
+ }
+
+ /**
+ * Sets the tags.
+ *
+ * @param tags The tags.
+ */
+ public final synchronized void setTags(List tags)
+ {
+ _tags.addAll(tags);
+ }
+
+ /**
+ * Sets the tags.
+ *
+ * @param tags The space-delimited tags.
+ */
+ public final synchronized void setTags(String tags)
+ {
+ if (tags != null)
+ {
+ final String[] parts = tags.split(" ");
+
+ SyndCategoryImpl tag;
+ String part;
+ char mod;
+
+ for (int i = 0; i < parts.length; i++)
+ {
+ part = parts[i].trim();
+
+ if (part.length() > 2)
+ {
+ tag = new SyndCategoryImpl();
+ tag.setName(part.substring(1).toLowerCase());
+
+ mod = part.charAt(0);
+
+ if (mod == '-')
+ {
+ // Don't remove the channel tag, if any.
+ if (!tag.getName().equals(_channel.substring(1)))
+ {
+ _tags.remove(tag);
+ }
+ }
+ else if (mod == '+')
+ {
+ if (!_tags.contains(tag))
+ {
+ _tags.add(tag);
+ }
+ }
+ else
+ {
+ tag.setName(part.trim().toLowerCase());
+
+ if (!_tags.contains(tag))
+ {
+ _tags.add(tag);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Sets the comment's title.
+ *
+ * @param title The new title.
+ */
+ public final synchronized void setTitle(String title)
+ {
+ _title = title;
}
}
diff --git a/src/net/thauvin/erik/mobibot/Mobibot.java b/src/net/thauvin/erik/mobibot/Mobibot.java
index 658e17c..02b598a 100644
--- a/src/net/thauvin/erik/mobibot/Mobibot.java
+++ b/src/net/thauvin/erik/mobibot/Mobibot.java
@@ -88,7 +88,7 @@ public class Mobibot extends PircBot
private static final String[] INFO_STRS =
{
"Mobibot v" + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber() +
- " by Erik C. Thauvin (erik@thauvin.net)", "http://www.thauvin.net/mobitopia/mobibot/"
+ " by Erik C. Thauvin (erik@thauvin.net)", "http://mobitopia.thauvin.net/mobibot/"
};
/**
@@ -181,6 +181,11 @@ public class Mobibot extends PircBot
*/
private static final String HELP_POSTING_KEYWORD = "posting";
+ /**
+ * The help on tags keyword.
+ */
+ private static final String HELP_TAGS_KEYWORD = "tags";
+
/**
* The Google command.
*/
@@ -251,6 +256,11 @@ public class Mobibot extends PircBot
*/
private static final String NO_TITLE = "No Title";
+ /**
+ * The tags/categories marker.
+ */
+ private static final String TAGS_MARKER = "tags:";
+
/**
* The countries supporte by the {@link #TIME_CMD time} command.
*/
@@ -336,6 +346,7 @@ public class Mobibot extends PircBot
COUNTRIES_MAP.put("NL", "Europe/Amsterdam");
COUNTRIES_MAP.put("NO", "Europe/Oslo");
COUNTRIES_MAP.put("NZ", "Pacific/Auckland");
+ COUNTRIES_MAP.put("PK", "Asia/Karachi");
COUNTRIES_MAP.put("RU", "Europe/Moscow");
COUNTRIES_MAP.put("SE", "Europe/Stockholm");
COUNTRIES_MAP.put("SG", "Asia/Singapore");
@@ -368,7 +379,7 @@ public class Mobibot extends PircBot
/**
* The number of milliseconds to delay between consecutive messages.
*/
- private static final int MESSAGE_DELAY = 1000;
+ private static final long MESSAGE_DELAY = 1000L;
/**
* The name of the file containing the current entries.
@@ -380,11 +391,6 @@ public class Mobibot extends PircBot
*/
private static final String NAV_XML = "nav.xml";
- /**
- * The del.icio.us posts handler.
- */
- private static DeliciousPoster _delicious = null;
-
/**
* The backlogs URL.
*/
@@ -395,6 +401,16 @@ public class Mobibot extends PircBot
*/
private final String _channel;
+ /**
+ * The default tags/categories.
+ */
+ private String _defaultTags = "";
+
+ /**
+ * The del.icio.us posts handler.
+ */
+ private DeliciousPoster _delicious = null;
+
/**
* The entries array.
*/
@@ -410,7 +426,10 @@ public class Mobibot extends PircBot
*/
private String _feedURL = "";
- // The Google API key.
+ /**
+ * The Google API key.
+ */
+
private String _googleKey = "";
/**
@@ -637,14 +656,6 @@ public class Mobibot extends PircBot
System.setErr(stderr);
}
- // Get the del.icio.us properties
- final String dname = p.getProperty("delicious-user");
- final String dpwd = p.getProperty("delicious-pwd");
-
- if (isValidString(dname) && isValidString(dpwd))
- {
- _delicious = new DeliciousPoster(dname, dpwd, p.getProperty("delicious-tags", ""));
- }
// Get the bot's properties
final String login = p.getProperty("login", nickname);
@@ -653,6 +664,11 @@ public class Mobibot extends PircBot
final String backlogsURL = ensureDir(p.getProperty("backlogs", weblogURL), true);
final String googleKey = p.getProperty("google", "");
final String ignoredNicks = p.getProperty("ignore", "");
+ final String tags = p.getProperty("tags", "");
+
+ // Get the del.icio.us properties
+ final String dname = p.getProperty("delicious-user");
+ final String dpwd = p.getProperty("delicious-pwd");
// Create the bot
final Mobibot bot = new Mobibot(server, channel, logsDir);
@@ -673,6 +689,16 @@ 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);
+ }
+
+ // Set the tags
+ bot.setTags(tags);
+
// Set the ignored nicks
bot.setIgnoredNicks(ignoredNicks);
@@ -753,7 +779,7 @@ public class Mobibot extends PircBot
{
if (isValidString(channel) && isValidString(action))
{
- this.sendAction(channel, action);
+ sendAction(channel, action);
}
}
@@ -799,7 +825,8 @@ public class Mobibot extends PircBot
if (lcTopic.endsWith(HELP_POSTING_KEYWORD))
{
- send(sender, bold("Post a URL, by saying it on a line on its own."));
+ send(sender, bold("Post a URL, by saying it on a line on its own:"));
+ send(sender, DOUBLE_INDENT + bold(" [] [" + TAGS_MARKER + "<+tag> [...]]"));
send(sender, "I will reply with a label, for example: " + bold(LINK_CMD + '1'));
send(sender, "To add a title, use a its label and a pipe:");
send(sender, DOUBLE_INDENT + bold(LINK_CMD + "1:|This is the title"));
@@ -812,6 +839,11 @@ public class Mobibot extends PircBot
send(sender, DOUBLE_INDENT + bold(LINK_CMD + "1.1:-"));
send(sender, "You can also view a posting by saying its label.");
}
+ else if (lcTopic.endsWith(HELP_TAGS_KEYWORD))
+ {
+ send(sender, bold("To categorize or tag a URL, use its label and a T:"));
+ send(sender, DOUBLE_INDENT + bold(LINK_CMD + "1T:<+tag|-tag> [...]"));
+ }
else if (lcTopic.endsWith(VIEW_CMD))
{
send(sender, "To list or search the current URL posts:");
@@ -938,7 +970,9 @@ public class Mobibot extends PircBot
bold(INFO_CMD + ' ' + getChannel().substring(1) + ' ' + LOOKUP_CMD + ' ' + HELP_POSTING_KEYWORD + ' ' +
RECAP_CMD));
send(sender,
- DOUBLE_INDENT + bold(SPELL_CMD + ' ' + STOCK_CMD + ' ' + TIME_CMD + ' ' + USERS_CMD + ' ' + VIEW_CMD));
+ DOUBLE_INDENT +
+ bold(SPELL_CMD + ' ' + STOCK_CMD + ' ' + HELP_TAGS_KEYWORD + ' ' + TIME_CMD + ' ' + USERS_CMD + ' ' +
+ VIEW_CMD));
send(sender, DOUBLE_INDENT + bold(WEATHER_CMD));
if (isOp(sender))
@@ -978,7 +1012,7 @@ public class Mobibot extends PircBot
_logger.debug("Sending message to " + sender + ": " + message);
}
- this.sendMessage(sender, message);
+ sendMessage(sender, message);
}
else
{
@@ -987,7 +1021,7 @@ public class Mobibot extends PircBot
_logger.debug("Sending notice to " + sender + ": " + message);
}
- this.sendNotice(sender, message);
+ sendNotice(sender, message);
}
}
}
@@ -1102,7 +1136,18 @@ public class Mobibot extends PircBot
if (title.indexOf(getNick()) == -1)
{
- _entries.add(new EntryLink(cmd, title, sender, login));
+ final int tagSep = title.lastIndexOf(TAGS_MARKER);
+
+ if (tagSep != -1)
+ {
+ _entries.add(new EntryLink(cmd, title.substring(0, tagSep), sender, login, channel,
+ (_defaultTags + ' ' +
+ title.substring(tagSep + TAGS_MARKER.length()))));
+ }
+ else
+ {
+ _entries.add(new EntryLink(cmd, title, sender, login, channel, _defaultTags));
+ }
}
else
{
@@ -1111,7 +1156,7 @@ public class Mobibot extends PircBot
}
else
{
- _entries.add(new EntryLink(cmd, NO_TITLE, sender, login));
+ _entries.add(new EntryLink(cmd, NO_TITLE, sender, login, channel, _defaultTags));
}
if (isCommand)
@@ -1122,7 +1167,7 @@ public class Mobibot extends PircBot
if (_delicious != null)
{
- _delicious.addPost(entry, postedBy(entry, channel));
+ _delicious.addPost(entry);
}
saveEntries(isBackup);
@@ -1354,6 +1399,11 @@ public class Mobibot extends PircBot
final EntryLink entry = (EntryLink) _entries.get(index);
send(getChannel(), buildLink(index, entry));
+ if (entry.hasTags())
+ {
+ send(getChannel(), buildTags(index, entry));
+ }
+
if (entry.hasComments())
{
final EntryComment[] comments = entry.getComments();
@@ -1395,7 +1445,7 @@ public class Mobibot extends PircBot
if (_delicious != null)
{
- _delicious.addPost(entry, postedBy(entry, channel));
+ _delicious.addPost(entry);
}
send(getChannel(), buildLink(index, entry));
@@ -1412,16 +1462,13 @@ public class Mobibot extends PircBot
if (link.matches(LINK_MATCH))
{
- if (_delicious != null)
- {
- _delicious.deletePost(entry);
- }
+ final String oldLink = entry.getLink();
entry.setLink(link);
if (_delicious != null)
{
- _delicious.addPost(entry, postedBy(entry, channel));
+ _delicious.updatePost(oldLink, entry);
}
send(getChannel(), buildLink(index, entry));
@@ -1462,6 +1509,51 @@ public class Mobibot extends PircBot
}
}
}
+ else if (message.matches(LINK_CMD + "[0-9]+T:.*"))
+ {
+ isCommand = true;
+
+ final String[] cmds = message.substring(1).split("T:", 2);
+ final int index = Integer.parseInt(cmds[0]) - 1;
+
+ if (index < _entries.size())
+ {
+ final String cmd = cmds[1].trim();
+
+ final EntryLink entry = (EntryLink) _entries.get(index);
+
+ if (cmd.length() != 0)
+ {
+ if (entry.getLogin().equals(login) || isOp(sender))
+ {
+ entry.setTags(cmd);
+
+ if (_delicious != null)
+ {
+ _delicious.addPost(entry);
+ }
+
+ send(getChannel(), buildTags(index, entry));
+ saveEntries(false);
+ }
+ else
+ {
+ send(sender, "Please ask a channel op to change the tags for you.");
+ }
+ }
+ else
+ {
+ if (entry.hasTags())
+ {
+ send(getChannel(), buildTags(index, entry));
+ }
+ else
+ {
+ send(sender, "The entry has no tags. Why don't add some?");
+ }
+ }
+ }
+ }
else if (message.matches(LINK_CMD + "[0-9]+\\.[0-9]+:.*"))
{
isCommand = true;
@@ -1556,7 +1648,7 @@ public class Mobibot extends PircBot
{
if (isOp(sender))
{
- this.sendRawLine("QUIT : Poof!");
+ sendRawLine("QUIT : Poof!");
System.exit(0);
}
}
@@ -1567,7 +1659,7 @@ public class Mobibot extends PircBot
send(getChannel(), sender + " has just signed my death sentence.");
saveEntries(true);
sleep(3);
- this.quitServer("The Bot Is Out There!");
+ quitServer("The Bot Is Out There!");
System.exit(0);
}
}
@@ -1575,9 +1667,9 @@ public class Mobibot extends PircBot
{
send(getChannel(), sender + " has just asked me to leave. I'll be back!");
sleep(0);
- this.partChannel(getChannel());
+ partChannel(getChannel());
sleep(5);
- this.joinChannel(getChannel());
+ joinChannel(getChannel());
}
else if (cmd.equals(RECAP_CMD))
{
@@ -1613,7 +1705,7 @@ public class Mobibot extends PircBot
{
if (isOp(sender))
{
- this.changeNick(args);
+ changeNick(args);
}
}
else if (cmd.startsWith(SAY_CMD))
@@ -1746,6 +1838,19 @@ public class Mobibot extends PircBot
return buff.toString();
}
+ /**
+ * Build an entry's tags/categories for diplay on the channel.
+ *
+ * @param entryIndex The entry's index.
+ * @param entry The {@link EntryLink entry} object.
+ *
+ * @return The entry's tags.
+ */
+ private static String buildTags(int entryIndex, EntryLink entry)
+ {
+ return (LINK_CMD + (entryIndex + 1) + "T: " + entry.getDeliciousTags());
+ }
+
/**
* Ensures that the given location (File/URL) has a trailing slash (/
) to indicate a directory.
*
@@ -2123,7 +2228,7 @@ public class Mobibot extends PircBot
*/
private boolean isOp(String sender)
{
- final User[] users = this.getUsers(getChannel());
+ final User[] users = getUsers(getChannel());
User user;
@@ -2153,10 +2258,10 @@ public class Mobibot extends PircBot
{
_history.clear();
- SyndFeedInput input = new SyndFeedInput();
- SyndFeed feed = input.build(new InputStreamReader(new FileInputStream(new File(file))));
+ final SyndFeedInput input = new SyndFeedInput();
+ final SyndFeed feed = input.build(new InputStreamReader(new FileInputStream(new File(file))));
- List items = feed.getEntries();
+ final List items = feed.getEntries();
SyndEntry item;
for (int i = items.size() - 1; i >= 0; i--)
@@ -2179,12 +2284,12 @@ public class Mobibot extends PircBot
{
_entries.clear();
- SyndFeedInput input = new SyndFeedInput();
- SyndFeed feed = input.build(new InputStreamReader(new FileInputStream(new File(file))));
+ final SyndFeedInput input = new SyndFeedInput();
+ final SyndFeed feed = input.build(new InputStreamReader(new FileInputStream(new File(file))));
setToday(ISO_SDF.format(feed.getPublishedDate()));
- List items = feed.getEntries();
+ final List items = feed.getEntries();
SyndEntry item;
SyndContent description;
String[] comments;
@@ -2196,7 +2301,8 @@ public class Mobibot extends PircBot
{
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, item.getPublishedDate());
+ entry = new EntryLink(item.getLink(), item.getTitle(), author, getChannel(), item.getPublishedDate(),
+ item.getCategories());
description = item.getDescription();
comments = description.getValue().split("
");
@@ -2274,19 +2380,6 @@ public class Mobibot extends PircBot
}
- /**
- * Returns he del.icio.us extended attribution line.
- *
- * @param entry The entry.
- * @param channel The channel
- *
- * @return The extended attribution line.
- */
- private String postedBy(EntryLink entry, String channel)
- {
- return "Posted by " + entry.getNick() + " on " + channel + " (" + _ircServer + ')';
- }
-
/**
* Stores the last 10 public messages and actions.
*
@@ -2350,7 +2443,7 @@ public class Mobibot extends PircBot
EntryLink entry;
StringBuffer buff;
EntryComment comment;
- final List items = new ArrayList();
+ final List items = new ArrayList(0);
SyndEntry item;
SyndContent description;
@@ -2385,6 +2478,7 @@ public class Mobibot extends PircBot
item.setTitle(entry.getTitle());
item.setPublishedDate(entry.getDate());
item.setAuthor(getChannel().substring(1) + '@' + _ircServer + " (" + entry.getNick() + ')');
+ item.setCategories(entry.getTags());
items.add(item);
}
@@ -2490,6 +2584,17 @@ public class Mobibot extends PircBot
_backlogsURL = backlogsURL;
}
+ /**
+ * Sets the del.icio.us authentication.
+ *
+ * @param username The del.icio.us username.
+ * @param password The del.icio.us password.
+ */
+ private void setDeliciousAuth(String username, String password)
+ {
+ _delicious = new DeliciousPoster(username, password, _ircServer);
+ }
+
/**
* Sets the feed URL.
*
@@ -2528,6 +2633,16 @@ public class Mobibot extends PircBot
}
}
+ /**
+ * Sets the default tags/categories.
+ *
+ * @param tags The tags.
+ */
+ private void setTags(String tags)
+ {
+ _defaultTags = tags;
+ }
+
/**
* Set today's date.
*
@@ -2648,7 +2763,7 @@ public class Mobibot extends PircBot
*/
private void usersResponse(String sender, boolean isPrivate)
{
- final User[] users = this.getUsers(getChannel());
+ final User[] users = getUsers(getChannel());
final String[] nicks = new String[users.length];
for (int i = 0; i < users.length; i++)
diff --git a/src/net/thauvin/erik/mobibot/ReleaseInfo.java b/src/net/thauvin/erik/mobibot/ReleaseInfo.java
index 1cd8149..3d00934 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 Sun Mar 06 13:05:37 PST 2005 */
+/* Creation date Thu May 05 12:13:41 PDT 2005 */
package net.thauvin.erik.mobibot;
import java.util.Date;
@@ -12,21 +12,21 @@ import java.util.Date;
public class ReleaseInfo {
- /** buildDate (set during build process to 1110143137218L). */
- private static Date buildDate = new Date(1110143137218L);
+ /** buildDate (set during build process to 1115320421004L). */
+ private static Date buildDate = new Date(1115320421004L);
/**
- * Get buildDate (set during build process to Sun Mar 06 13:05:37 PST 2005).
+ * Get buildDate (set during build process to Thu May 05 12:13:41 PDT 2005).
* @return Date buildDate
*/
public static final Date getBuildDate() { return buildDate; }
/**
- * Get buildNumber (set during build process to 3).
+ * Get buildNumber (set during build process to 26).
* @return int buildNumber
*/
- public static final int getBuildNumber() { return 3; }
+ public static final int getBuildNumber() { return 26; }
/** version (set during build process to "0.3"). */
diff --git a/src/net/thauvin/erik/mobibot/StockQuote.java b/src/net/thauvin/erik/mobibot/StockQuote.java
index f71ff4b..fb765e0 100644
--- a/src/net/thauvin/erik/mobibot/StockQuote.java
+++ b/src/net/thauvin/erik/mobibot/StockQuote.java
@@ -45,11 +45,10 @@ import java.io.IOException;
/**
* Retrieves a stock quote from Yahoo!.
*
- * @author Erik C. Thauvin
+ * @author Erik C. Thauvin
* @version $Revision$, $Date$
- *
* @created Feb 7, 2004
- * @since 1.0
+ * @since 1.0
*/
public class StockQuote implements Runnable
{
@@ -76,7 +75,7 @@ public class StockQuote implements Runnable
/**
* Creates a new StockQuote object.
*
- * @param bot The bot.
+ * @param bot The bot.
* @param sender The nick of the person who sent the message.
* @param symbol The stock symbol.
*/
@@ -95,8 +94,8 @@ public class StockQuote implements Runnable
try
{
final HttpClient client = new HttpClient();
- client.setConnectionTimeout(Mobibot.CONNECT_TIMEOUT);
- client.setTimeout(Mobibot.CONNECT_TIMEOUT);
+ client.getHttpConnectionManager().getParams().setConnectionTimeout(Mobibot.CONNECT_TIMEOUT);
+ client.getHttpConnectionManager().getParams().setSoTimeout(Mobibot.CONNECT_TIMEOUT);
final GetMethod getMethod = new GetMethod(YAHOO_URL + _symbol.toUpperCase());
client.executeMethod(getMethod);
@@ -108,8 +107,7 @@ public class StockQuote implements Runnable
if ((quote.length > 3) && (!"\"N/A\"".equalsIgnoreCase(quote[3])))
{
_bot.send(_bot.getChannel(),
- "Symbol: " + quote[0].replaceAll("\"", "") + " [" + quote[1].replaceAll("\"", "") +
- ']');
+ "Symbol: " + quote[0].replaceAll("\"", "") + " [" + quote[1].replaceAll("\"", "") + ']');
if (quote.length > 5)
{
@@ -123,7 +121,7 @@ public class StockQuote implements Runnable
if (quote.length > 4)
{
_bot.send(_sender,
- "Time: " + quote[3].replaceAll("\"", "") + ' ' + quote[4].replaceAll("\"", ""));
+ "Time: " + quote[3].replaceAll("\"", "") + ' ' + quote[4].replaceAll("\"", ""));
}
if (quote.length > 6)