diff --git a/.cvsignore b/.cvsignore
index 3369402..53371c3 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,8 +1,9 @@
-DevSuite
-build
-dist
-log4j.properties
-mobibot.properties
-fetcher.properties
-*.ser
-logs
\ No newline at end of file
+DevSuite
+build
+dist
+log4j.properties
+mobibot.properties
+fetcher.properties
+*.ser
+logs
+.git
diff --git a/buildnum.properties b/buildnum.properties
index 8640ea3..e07de5f 100644
--- a/buildnum.properties
+++ b/buildnum.properties
@@ -1,3 +1,3 @@
-#ANT Task: ch.oscg.jreleaseinfo.BuildNumberHandler
-#Mon Oct 04 00:59:22 PDT 2010
-build.num.last=2
+#ANT Task: ch.oscg.jreleaseinfo.BuildNumberHandler
+#Fri Jun 29 06:58:32 PDT 2012
+build.num.last=3
diff --git a/lib/jsoup-1.6.3.jar b/lib/jsoup-1.6.3.jar
new file mode 100644
index 0000000..b3421d5
Binary files /dev/null and b/lib/jsoup-1.6.3.jar differ
diff --git a/mobibot.iml b/mobibot.iml
index c27d878..ca3aa60 100644
--- a/mobibot.iml
+++ b/mobibot.iml
@@ -161,6 +161,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/mobibot.ipr b/mobibot.ipr
index 1eac796..9c565c9 100644
--- a/mobibot.ipr
+++ b/mobibot.ipr
@@ -138,7 +138,9 @@
-
+
+
+
@@ -146,7 +148,7 @@
-
+
@@ -172,7 +174,13 @@
-
+
+
+
+
+
@@ -181,6 +189,7 @@
+
@@ -199,9 +208,9 @@
+
-
@@ -214,6 +223,7 @@
+
@@ -224,7 +234,9 @@
-
+
+
+
@@ -252,7 +264,9 @@
-
+
+
+
@@ -294,6 +308,9 @@
+
@@ -308,7 +325,9 @@
-
+
+
+
@@ -358,14 +377,6 @@
-
-
-
-
@@ -572,7 +583,7 @@
-
+
diff --git a/mobibot.iws b/mobibot.iws
index dbbb4ad..2ceddf4 100644
--- a/mobibot.iws
+++ b/mobibot.iws
@@ -33,14 +33,18 @@
-
+
+
-
+
+
+
+
-
-
+
+
@@ -55,7 +59,6 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -146,19 +160,10 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -167,7 +172,34 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -181,8 +213,7 @@
-
-
+
@@ -195,7 +226,6 @@
@@ -263,6 +294,11 @@
+
+
+
+
+
@@ -279,7 +315,7 @@
-
+
@@ -325,7 +361,7 @@
-
+
@@ -337,36 +373,46 @@
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
-
-
@@ -395,7 +441,7 @@
-
+
@@ -409,12 +455,41 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -435,14 +510,14 @@
-
+
-
-
+
+
@@ -458,7 +533,7 @@
-
+
@@ -474,8 +549,8 @@
-
+
@@ -485,8 +560,8 @@
-
+
@@ -505,23 +580,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -534,7 +592,35 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -543,7 +629,7 @@
-
+
@@ -576,27 +662,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -615,43 +682,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -669,6 +701,7 @@
+
@@ -676,9 +709,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -702,7 +761,6 @@
-
@@ -778,11 +836,12 @@
-
+
+
+
-
@@ -791,6 +850,7 @@
+
C:\Users\erik\AppData\Roaming\Subversion
true
125
@@ -824,23 +884,27 @@
-
-
+
+
+
+
-
+
+
+
+
-
+
-
-
-
+
+
@@ -852,17 +916,16 @@
-
-
-
+
+
@@ -875,9 +938,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -887,7 +962,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -953,6 +1040,7 @@
+
@@ -966,16 +1054,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1021,32 +1099,47 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
+
-
+
-
+
-
-
+
+
+
+
+
@@ -1097,34 +1190,78 @@
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
-
-
+
-
-
+
+
+
+ No facets are configured
-
+
+
+
+
+
-
+
-
-
+
+
+ commons-logging-api
-
+
+
+
+
+
-
-
+
+
+
+ 1.7.x
+
+
+
+
+
+
+
+
+
+
+
+ mobibot
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/net/thauvin/erik/mobibot/EntryLink.java b/src/net/thauvin/erik/mobibot/EntryLink.java
index cdcba20..942c020 100644
--- a/src/net/thauvin/erik/mobibot/EntryLink.java
+++ b/src/net/thauvin/erik/mobibot/EntryLink.java
@@ -191,7 +191,7 @@ public class EntryLink implements Serializable
*/
public final synchronized EntryComment[] getComments()
{
- return ((EntryComment[]) _comments.toArray(new EntryComment[0]));
+ return ((EntryComment[]) _comments.toArray(new EntryComment[_comments.size()]));
}
/**
@@ -217,19 +217,15 @@ public class EntryLink implements Serializable
/**
* Returns the tags formatted for del.icio.us.
*
- * @return The tags as a space-deliminted string.
+ * @return The tags as a comma-delimited string.
*/
public final synchronized String getDeliciousTags()
{
- final StringBuffer tags = new StringBuffer(0);
+ final StringBuffer tags = new StringBuffer(_nick);
for (int i = 0; i < _tags.size(); i++)
{
- if (i != 0)
- {
- tags.append(' ');
- }
-
+ tags.append(',');
tags.append(((SyndCategoryImpl) _tags.get(i)).getName());
}
diff --git a/src/net/thauvin/erik/mobibot/Mobibot.java b/src/net/thauvin/erik/mobibot/Mobibot.java
index 85962fd..a117ede 100644
--- a/src/net/thauvin/erik/mobibot/Mobibot.java
+++ b/src/net/thauvin/erik/mobibot/Mobibot.java
@@ -50,6 +50,8 @@ import org.apache.log4j.Level;
import org.jibble.pircbot.Colors;
import org.jibble.pircbot.PircBot;
import org.jibble.pircbot.User;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
import java.io.*;
import java.net.InetAddress;
@@ -94,12 +96,11 @@ public class Mobibot extends PircBot
* The version strings.
*/
private static final String[] VERSION_STRS =
- {"Version: " + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber() + " ("
- + ISO_SDF.format(ReleaseInfo.getBuildDate()) + ')',
- "Platform: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ", "
- + System.getProperty("os.arch") + ", " + System.getProperty("user.country") + ')',
- "Runtime: " + System.getProperty("java.runtime.name") + " (build "
- + System.getProperty("java.runtime.version") + ')',
+ {"Version: " + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber() + " (" + ISO_SDF.format(ReleaseInfo.getBuildDate()) + ')',
+ "Platform: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ", " + System
+ .getProperty("os.arch") + ", " + System.getProperty("user.country") + ')',
+ "Runtime: " + System.getProperty("java.runtime.name") + " (build " + System
+ .getProperty("java.runtime.version") + ')',
"VM: " + System.getProperty("java.vm.name") + " (build " + System.getProperty("java.vm.version") + ", "
+ System.getProperty("java.vm.info") + ')'};
@@ -613,7 +614,7 @@ public class Mobibot extends PircBot
*
* @param args The command line arguments.
*
- * @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE
+ * @noinspection UseOfSystemOutOrSystemErr, ACCESS_STATIC_VIA_INSTANCE
*/
public static void main(String[] args)
{
@@ -625,7 +626,7 @@ public class Mobibot extends PircBot
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();
@@ -1314,59 +1315,67 @@ public class Mobibot extends PircBot
isCommand = true;
final String[] cmds = message.split(" ", 2);
- final String cmd = cmds[0].trim();
- boolean isBackup = false;
- final int dupIndex = findDupEntry(cmd);
-
- if (dupIndex == -1)
+ if (cmds.length == 1 || (cmds[1].indexOf(getNick()) == -1))
{
- if (!today().equals(getToday()))
+ final String link = cmds[0].trim();
+ boolean isBackup = false;
+
+ final int dupIndex = findDupEntry(link);
+
+ if (dupIndex == -1)
{
- isBackup = true;
- saveEntries(isBackup);
-
- _entries.clear();
- setToday(today());
- }
-
- final boolean hasTitle = (cmds.length > 1) && (cmds[1].trim().length() > 0);
-
- if (hasTitle)
- {
- final String title = cmds[1].trim();
-
- if (title.indexOf(getNick()) == -1)
+ if (!today().equals(getToday()))
{
- final int tagSep = title.lastIndexOf(TAGS_MARKER);
+ isBackup = true;
+ saveEntries(isBackup);
- if (tagSep != -1)
+ _entries.clear();
+ setToday(today());
+ }
+
+ final StringBuffer tags = new StringBuffer(_defaultTags);
+ String title = NO_TITLE;
+
+ if (cmds.length == 2)
+ {
+ final String[] data = cmds[1].trim().split(TAGS_MARKER, 2);
+
+ if (data.length == 1)
{
- _entries.add(new EntryLink(cmd,
- title.substring(0, tagSep),
- sender,
- login,
- channel,
- (_defaultTags + ' ' + title
- .substring(tagSep + TAGS_MARKER.length()))));
+ title = data[0].trim();
}
else
{
- _entries.add(new EntryLink(cmd, title, sender, login, channel, _defaultTags));
+ if (isValidString(data[0]))
+ {
+ title = data[0].trim();
+ }
+
+ tags.append(' ').append(data[1].trim());
}
}
- else
- {
- isCommand = false;
- }
- }
- else
- {
- _entries.add(new EntryLink(cmd, NO_TITLE, sender, login, channel, _defaultTags));
- }
- if (isCommand)
- {
+ if (NO_TITLE.equals(title))
+ {
+ try
+ {
+ final Document html = Jsoup.connect(link).get();
+ final String htmlTitle = html.title();
+
+ if (isValidString(htmlTitle))
+ {
+ title = htmlTitle;
+ }
+ }
+ catch (IOException ignore)
+ {
+ // Do nothing
+ }
+ }
+
+ _entries.add(new EntryLink(link, title, sender, login, channel, tags.toString()));
+
final int index = _entries.size() - 1;
final EntryLink entry = (EntryLink) _entries.get(index);
send(channel, buildLink(index, entry));
@@ -1378,17 +1387,17 @@ public class Mobibot extends PircBot
saveEntries(isBackup);
- if (!hasTitle)
+ if (NO_TITLE.equals(entry.getTitle()))
{
send(sender, "Please specify a title, by typing:", true);
send(sender, DOUBLE_INDENT + bold(LINK_CMD + (index + 1) + ":|This is the title"), true);
}
}
- }
- else
- {
- final EntryLink entry = (EntryLink) _entries.get(dupIndex);
- send(sender, "Duplicate >> " + buildLink(dupIndex, entry));
+ else
+ {
+ final EntryLink entry = (EntryLink) _entries.get(dupIndex);
+ send(sender, "Duplicate >> " + buildLink(dupIndex, entry));
+ }
}
}
else if (message.matches(getNickPattern() + ":.*"))
@@ -2046,7 +2055,7 @@ public class Mobibot extends PircBot
*
* @return The entry's link.
*
- * @see #buildLink(int,EntryLink,boolean)
+ * @see #buildLink(int, EntryLink, boolean)
*/
private static String buildLink(int index, EntryLink entry)
{
@@ -2099,7 +2108,7 @@ public class Mobibot extends PircBot
*/
private static String buildTags(int entryIndex, EntryLink entry)
{
- return (LINK_CMD + (entryIndex + 1) + "T: " + entry.getDeliciousTags());
+ return (LINK_CMD + (entryIndex + 1) + "T: " + entry.getDeliciousTags().replaceAll(",", ", "));
}
/**
@@ -2527,8 +2536,8 @@ public class Mobibot extends PircBot
*/
private boolean isTwitterEnabled()
{
- return isValidString(_twitterConsumerKey) && isValidString(_twitterConsumerSecret)
- && isValidString(_twitterToken) && isValidString(_twitterTokenSecret);
+ return isValidString(_twitterConsumerKey) && isValidString(_twitterConsumerSecret) && isValidString(
+ _twitterToken) && isValidString(_twitterTokenSecret);
}
/**
@@ -2888,7 +2897,9 @@ public class Mobibot extends PircBot
{
entry = (EntryLink) _entries.get(i);
- buff = new StringBuffer("Posted by " + entry.getNick() + " on " + entry.getChannel() + "");
+ buff = new StringBuffer(
+ "Posted by " + entry.getNick() + " on " + entry.getChannel() + "");
if (entry.getCommentsCount() > 0)
{
@@ -3308,8 +3319,8 @@ public class Mobibot extends PircBot
if (lcArgs.length() > 0)
{
- if ((entry.getLink().toLowerCase().indexOf(lcArgs) != -1)
- || (entry.getTitle().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)
diff --git a/src/net/thauvin/erik/mobibot/ReleaseInfo.java b/src/net/thauvin/erik/mobibot/ReleaseInfo.java
index 85adc8b..ea5f250 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 Mon Oct 04 00:59:22 PDT 2010 */
+/* Creation date Fri Jun 29 06:58:32 PDT 2012 */
package net.thauvin.erik.mobibot;
import java.util.Date;
@@ -20,21 +20,21 @@ public class ReleaseInfo {
}
- /** buildDate (set during build process to 1286179162570L). */
- private static final Date buildDate = new Date(1286179162570L);
+ /** buildDate (set during build process to 1340978312640L). */
+ private static final Date buildDate = new Date(1340978312640L);
/**
- * Get buildDate (set during build process to Mon Oct 04 00:59:22 PDT 2010).
+ * Get buildDate (set during build process to Fri Jun 29 06:58:32 PDT 2012).
* @return Date buildDate
*/
public static Date getBuildDate() { return buildDate; }
/**
- * Get buildNumber (set during build process to 2).
+ * Get buildNumber (set during build process to 3).
* @return int buildNumber
*/
- public static int getBuildNumber() { return 2; }
+ public static int getBuildNumber() { return 3; }
/** project (set during build process to "mobibot"). */