-
-
+
\ No newline at end of file
diff --git a/src/main/java/net/thauvin/erik/mobibot/Commands.java b/src/main/java/net/thauvin/erik/mobibot/Commands.java
index 47dbedf..9d8b08c 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Commands.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Commands.java
@@ -1,7 +1,7 @@
/*
- * @(#)Commands.java
+ * Commands.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
/**
@@ -43,6 +42,16 @@ package net.thauvin.erik.mobibot;
*/
public class Commands
{
+ /**
+ * The add (back)log command.
+ */
+ public static final String ADDLOG_CMD = "addlog";
+
+ /**
+ * The math command.
+ */
+ public static final String CALC_CMD = "calc";
+
/**
* The currency command.
*/
@@ -54,35 +63,15 @@ public class Commands
public static final String CURRENCY_RATES_KEYWORD = "rates";
/**
- * The weather command.
+ * The cycle command.
*/
- public static final String WEATHER_CMD = "weather";
+ public static final String CYCLE_CMD = "cycle";
/**
* Debug command line argument.
*/
public static final String DEBUG_ARG = "debug";
- /**
- * Help command line argument.
- */
- public static final String HELP_ARG = "help";
-
- /**
- * Properties command line argument.
- */
- public static final String PROPS_ARG = "properties";
-
- /**
- * Properties version line argument.
- */
- public static final String VERSION_ARG = "version";
-
- /**
- * The add (back)log command.
- */
- public static final String ADDLOG_CMD = "addlog";
-
/**
* The debug command.
*/
@@ -93,35 +82,20 @@ public class Commands
*/
public static final String DICE_CMD = "dice";
- /**
- * The say command.
- */
- public static final String SAY_CMD = "say";
-
/**
* The die command.
*/
public static final String DIE_CMD = "die";
/**
- * The cycle command.
+ * The Google command.
*/
- public static final String CYCLE_CMD = "cycle";
+ public static final String GOOGLE_CMD = "google";
/**
- * The msg command.
+ * Help command line argument.
*/
- public static final String MSG_CMD = "msg";
-
- /**
- * The ignore command.
- */
- public static final String IGNORE_CMD = "ignore";
-
- /**
- * The ignore me keyword.
- */
- public static final String IGNORE_ME_KEYWORD = "me";
+ public static final String HELP_ARG = "help";
/**
* The help command.
@@ -139,29 +113,19 @@ public class Commands
public static final String HELP_TAGS_KEYWORD = "tags";
/**
- * The Google command.
+ * The ignore command.
*/
- public static final String GOOGLE_CMD = "google";
+ public static final String IGNORE_CMD = "ignore";
/**
- * The Twitter command.
+ * The ignore me keyword.
*/
- public static final String TWITTER_CMD = "twitter";
+ public static final String IGNORE_ME_KEYWORD = "me";
/**
- * The math command.
+ * The info command.
*/
- public static final String CALC_CMD = "calc";
-
- /**
- * The me command.
- */
- public static final String ME_CMD = "me";
-
- /**
- * The nick command.
- */
- public static final String NICK_CMD = "nick";
+ public static final String INFO_CMD = "info";
/**
* The link command.
@@ -173,6 +137,21 @@ public class Commands
*/
public static final String LOOKUP_CMD = "lookup";
+ /**
+ * The me command.
+ */
+ public static final String ME_CMD = "me";
+
+ /**
+ * The msg command.
+ */
+ public static final String MSG_CMD = "msg";
+
+ /**
+ * The nick command.
+ */
+ public static final String NICK_CMD = "nick";
+
/**
* The ping command.
*/
@@ -183,6 +162,11 @@ public class Commands
*/
public static final String PONG_CMD = "pong";
+ /**
+ * Properties command line argument.
+ */
+ public static final String PROPS_ARG = "properties";
+
/**
* The quote command.
*/
@@ -193,15 +177,20 @@ public class Commands
*/
public static final String RECAP_CMD = "recap";
+ /**
+ * The say command.
+ */
+ public static final String SAY_CMD = "say";
+
/**
* The stock command.
*/
public static final String STOCK_CMD = "stock";
/**
- * The time command.
+ * The {@link #TELL_CMD} all command.
*/
- public static final String TIME_CMD = "time";
+ public static final String TELL_ALL_CMD = "all";
/**
* The tell command.
@@ -214,14 +203,14 @@ public class Commands
public static final String TELL_DEL_CMD = "del";
/**
- * The {@link #TELL_CMD} all command.
+ * The time command.
*/
- public static final String TELL_ALL_CMD = "all";
+ public static final String TIME_CMD = "time";
/**
- * The war command.
+ * The Twitter command.
*/
- public static final String WAR_CMD = "war";
+ public static final String TWITTER_CMD = "twitter";
/**
* The users command.
@@ -229,9 +218,9 @@ public class Commands
public static final String USERS_CMD = "users";
/**
- * The info command.
+ * Properties version line argument.
*/
- public static final String INFO_CMD = "info";
+ public static final String VERSION_ARG = "version";
/**
* The version command.
@@ -243,10 +232,20 @@ public class Commands
*/
public static final String VIEW_CMD = "view";
+ /**
+ * The war command.
+ */
+ public static final String WAR_CMD = "war";
+
+ /**
+ * The weather command.
+ */
+ public static final String WEATHER_CMD = "weather";
+
/**
* Disables the default constructor.
*
- * @throws UnsupportedOperationException if an error occurred. if the constructor is called.
+ * @throws UnsupportedOperationException If the constructor is called.
*/
private Commands()
throws UnsupportedOperationException
diff --git a/src/main/java/net/thauvin/erik/mobibot/CurrencyConverter.java b/src/main/java/net/thauvin/erik/mobibot/CurrencyConverter.java
index 4d18356..f5936c9 100644
--- a/src/main/java/net/thauvin/erik/mobibot/CurrencyConverter.java
+++ b/src/main/java/net/thauvin/erik/mobibot/CurrencyConverter.java
@@ -1,7 +1,7 @@
/*
- * @(#)CurrencyConverter.java
+ * CurrencyConverter.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import org.jdom.Document;
@@ -54,21 +53,26 @@ import java.util.*;
*/
public class CurrencyConverter implements Runnable
{
- /**
- * The exchange rates table URL.
- */
- private static final String EXCHANGE_TABLE_URL = "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml";
-
/**
* The exchange rates.
*/
private static final Map EXCHANGE_RATES = new TreeMap();
+ /**
+ * The exchange rates table URL.
+ */
+ private static final String EXCHANGE_TABLE_URL = "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml";
+
/**
* The bot.
*/
private final Mobibot bot;
+ /**
+ * The last exchange rates table publication date.
+ */
+ private String pubDate = "";
+
/**
* The actual currency query.
*/
@@ -79,11 +83,6 @@ public class CurrencyConverter implements Runnable
*/
private String sender;
- /**
- * The last exchange rates table publication date.
- */
- private String pubDate = "";
-
/**
* Creates a new {@link CurrencyConverter} instance.
*
@@ -165,8 +164,7 @@ public class CurrencyConverter implements Runnable
NumberFormat.getCurrencyInstance(Locale.US).format(amt).substring(1) + ' ' +
cmds[1].toUpperCase() + " = " +
NumberFormat.getCurrencyInstance(Locale.US).format((amt * to) / from)
- .substring(1) + ' ' + cmds[3].toUpperCase()
- );
+ .substring(1) + ' ' + cmds[3].toUpperCase());
}
catch (NullPointerException ignored)
{
diff --git a/src/main/java/net/thauvin/erik/mobibot/DeliciousPoster.java b/src/main/java/net/thauvin/erik/mobibot/DeliciousPoster.java
index 36ef5ca..8dcce8b 100644
--- a/src/main/java/net/thauvin/erik/mobibot/DeliciousPoster.java
+++ b/src/main/java/net/thauvin/erik/mobibot/DeliciousPoster.java
@@ -1,7 +1,7 @@
/*
- * @(#)DeliciousPoster.java
+ * DeliciousPoster.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import del.icio.us.Delicious;
diff --git a/src/main/java/net/thauvin/erik/mobibot/Dice.java b/src/main/java/net/thauvin/erik/mobibot/Dice.java
index 7ffdc9f..7a324f4 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Dice.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Dice.java
@@ -1,7 +1,7 @@
/*
- * @(#)Dice.java
+ * Dice.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@ public class Dice
/**
* Disables the default constructor.
*
- * @throws UnsupportedOperationException if an error occurred. if the constructor is called.
+ * @throws UnsupportedOperationException If the constructor is called.
*/
private Dice()
throws UnsupportedOperationException
@@ -71,8 +71,7 @@ public class Dice
bot.send(bot.getChannel(),
sender + " rolled two dice: " + Utils.bold(i) + " and " + Utils.bold(y) + " for a total of " + Utils
- .bold(playerTotal)
- );
+ .bold(playerTotal));
i = r.nextInt(6) + 1;
y = r.nextInt(6) + 1;
diff --git a/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java b/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java
index 91ac6db..e28ae8c 100644
--- a/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java
+++ b/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java
@@ -1,7 +1,7 @@
/*
- * @(#)EntriesMgr.java
+ * EntriesMgr.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -75,7 +75,7 @@ public class EntriesMgr
/**
* Disables the default constructor.
*
- * @throws UnsupportedOperationException if an error occurred. if the constructor is called.
+ * @throws UnsupportedOperationException If the constructor is called.
*/
private EntriesMgr()
throws UnsupportedOperationException
@@ -83,6 +83,55 @@ public class EntriesMgr
throw new UnsupportedOperationException("Illegal constructor call.");
}
+ /**
+ * Loads the backlogs.
+ *
+ * @param file The file containing the backlogs.
+ * @param history The history list.
+ *
+ * @throws FileNotFoundException If the file was not found.
+ * @throws FeedException If an error occurred while reading the feed.
+ */
+ public static void loadBacklogs(String file, List history)
+ throws FileNotFoundException, FeedException
+ {
+ history.clear();
+
+ final SyndFeedInput input = new SyndFeedInput();
+
+ InputStreamReader reader = null;
+
+ try
+ {
+ reader = new InputStreamReader(new FileInputStream(new File(file)));
+
+ final SyndFeed feed = input.build(reader);
+
+ final List items = feed.getEntries();
+ SyndEntry item;
+
+ for (int i = items.size() - 1; i >= 0; i--)
+ {
+ item = (SyndEntryImpl) items.get(i);
+ history.add(item.getTitle());
+ }
+ }
+ finally
+ {
+ if (reader != null)
+ {
+ try
+ {
+ reader.close();
+ }
+ catch (IOException ignore)
+ {
+ ; // Do nothing
+ }
+ }
+ }
+ }
+
/**
* Loads the current entries.
*
@@ -167,55 +216,6 @@ public class EntriesMgr
return today;
}
- /**
- * Loads the backlogs.
- *
- * @param file The file containing the backlogs.
- * @param history The history list.
- *
- * @throws FileNotFoundException If the file was not found.
- * @throws FeedException If an error occurred while reading the feed.
- */
- public static void loadBacklogs(String file, List history)
- throws FileNotFoundException, FeedException
- {
- history.clear();
-
- final SyndFeedInput input = new SyndFeedInput();
-
- InputStreamReader reader = null;
-
- try
- {
- reader = new InputStreamReader(new FileInputStream(new File(file)));
-
- final SyndFeed feed = input.build(reader);
-
- final List items = feed.getEntries();
- SyndEntry item;
-
- for (int i = items.size() - 1; i >= 0; i--)
- {
- item = (SyndEntryImpl) items.get(i);
- history.add(item.getTitle());
- }
- }
- finally
- {
- if (reader != null)
- {
- try
- {
- reader.close();
- }
- catch (IOException ignore)
- {
- ; // Do nothing
- }
- }
- }
- }
-
/**
* Saves the entries.
*
@@ -260,8 +260,7 @@ public class EntriesMgr
buff = new StringBuffer(
"Posted by " + entry.getNick() + " on " + entry.getChannel() + ""
- );
+ + entry.getChannel() + "\">" + entry.getChannel() + "");
if (entry.getCommentsCount() > 0)
{
diff --git a/src/main/java/net/thauvin/erik/mobibot/EntryComment.java b/src/main/java/net/thauvin/erik/mobibot/EntryComment.java
index d7b26d8..1fe3eae 100644
--- a/src/main/java/net/thauvin/erik/mobibot/EntryComment.java
+++ b/src/main/java/net/thauvin/erik/mobibot/EntryComment.java
@@ -1,7 +1,7 @@
/*
- * @(#)EntryComment.java
+ * EntryComment.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import java.io.Serializable;
diff --git a/src/main/java/net/thauvin/erik/mobibot/EntryLink.java b/src/main/java/net/thauvin/erik/mobibot/EntryLink.java
index d734f6e..ceee3f3 100644
--- a/src/main/java/net/thauvin/erik/mobibot/EntryLink.java
+++ b/src/main/java/net/thauvin/erik/mobibot/EntryLink.java
@@ -1,7 +1,7 @@
/*
- * @(#)EntryLink.java
+ * EntryLink.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import com.sun.syndication.feed.synd.SyndCategoryImpl;
diff --git a/src/main/java/net/thauvin/erik/mobibot/FeedReader.java b/src/main/java/net/thauvin/erik/mobibot/FeedReader.java
index ffc91e9..f12f88d 100644
--- a/src/main/java/net/thauvin/erik/mobibot/FeedReader.java
+++ b/src/main/java/net/thauvin/erik/mobibot/FeedReader.java
@@ -1,7 +1,7 @@
/*
- * @(#)FeedReader.java
+ * FeedReader.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import com.sun.syndication.feed.synd.SyndEntry;
diff --git a/src/main/java/net/thauvin/erik/mobibot/GoogleSearch.java b/src/main/java/net/thauvin/erik/mobibot/GoogleSearch.java
index 7a01981..4032836 100644
--- a/src/main/java/net/thauvin/erik/mobibot/GoogleSearch.java
+++ b/src/main/java/net/thauvin/erik/mobibot/GoogleSearch.java
@@ -1,7 +1,7 @@
/*
- * @(#)GoogleSearch.java
+ * GoogleSearch.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import org.json.JSONArray;
diff --git a/src/main/java/net/thauvin/erik/mobibot/Lookup.java b/src/main/java/net/thauvin/erik/mobibot/Lookup.java
index c3a20b1..d42c2a3 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Lookup.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Lookup.java
@@ -1,7 +1,7 @@
/*
- * @(#)Lookup.java
+ * Lookup.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import org.apache.commons.net.WhoisClient;
@@ -59,7 +58,7 @@ public class Lookup
/**
* Disables the default constructor.
*
- * @throws UnsupportedOperationException if an error occurred. if the constructor is called.
+ * @throws UnsupportedOperationException If the constructor is called.
*/
private Lookup()
throws UnsupportedOperationException
diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
index b779157..77308f3 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
@@ -1,7 +1,7 @@
/*
- * @(#)Mobibot.java
+ * Mobibot.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -83,21 +83,11 @@ public class Mobibot extends PircBot
private static final int DEFAULT_TELL_MAX_DAYS = 7;
- /**
- * The number of days message are kept.
- */
- private int tellMaxDays = DEFAULT_TELL_MAX_DAYS;
-
/**
* The default {@link Commands#TELL_CMD) message max queue size.
*/
private static final int DEFAULT_TELL_MAX_SIZE = 50;
- /**
- * The maximum number of {@link Commands#TELL_CMD} messages allowed.
- */
- private int tellMaxSize = DEFAULT_TELL_MAX_SIZE;
-
/**
* The double tab indent (8 spaces).
*/
@@ -280,6 +270,16 @@ public class Mobibot extends PircBot
*/
private String identNick = "";
+ /**
+ * The number of days message are kept.
+ */
+ private int tellMaxDays = DEFAULT_TELL_MAX_DAYS;
+
+ /**
+ * The maximum number of {@link Commands#TELL_CMD} messages allowed.
+ */
+ private int tellMaxSize = DEFAULT_TELL_MAX_SIZE;
+
/**
* Today's date.
*/
@@ -1301,8 +1301,7 @@ public class Mobibot extends PircBot
send(sender,
DOUBLE_INDENT + Utils
.bold(Commands.CYCLE_CMD + " " + Commands.ME_CMD + " " + Commands.MSG_CMD + " "
- + Commands.SAY_CMD + " " + Commands.VERSION_CMD)
- );
+ + Commands.SAY_CMD + " " + Commands.VERSION_CMD));
}
}
}
@@ -1401,8 +1400,7 @@ public class Mobibot extends PircBot
send(sender,
"Uptime: " + days + " day(s) " + hours + " hour(s) " + minutes + " minute(s) [Entries: " + entries.size()
+ (isTellEnabled() && isOp(sender) ? ", Messages: " + tellMessages.size() : "") + ']',
- isPrivate
- );
+ isPrivate);
}
/**
@@ -2268,8 +2266,7 @@ public class Mobibot extends PircBot
private void recap(String sender, String message, boolean isAction)
{
recap.add(Utils.UTC_SDF.format(Calendar.getInstance().getTime()) + " -> " + sender + (isAction ? " " : ": ")
- + message
- );
+ + message);
if (recap.size() > MAX_RECAP)
{
@@ -2321,8 +2318,7 @@ public class Mobibot extends PircBot
{
send(nickname,
Utils.bold("You") + " wanted me to remind you: " + Colors.REVERSE + message
- .getMessage() + Colors.REVERSE, true
- );
+ .getMessage() + Colors.REVERSE, true);
message.setIsReceived();
message.setIsNotified();
@@ -2335,8 +2331,7 @@ public class Mobibot extends PircBot
send(nickname,
message.getSender() + " wanted me to tell you: " + Colors.REVERSE + message
.getMessage() + Colors.REVERSE,
- true
- );
+ true);
message.setIsReceived();
@@ -2350,8 +2345,7 @@ public class Mobibot extends PircBot
"Your message " + Colors.REVERSE + "[ID " + message.getId() + ']' + Colors.REVERSE
+ " was sent to " + Utils.bold(message.getRecipient()) + " on " + Utils.UTC_SDF
.format(message.getReceived()),
- true
- );
+ true);
message.setIsNotified();
@@ -2471,8 +2465,7 @@ public class Mobibot extends PircBot
send(sender,
Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient()) + " [ID: "
+ message.getId() + ", " + (message.isReceived() ? "DELIVERED" : "QUEUED") + ']',
- true
- );
+ true);
}
}
else
@@ -2500,8 +2493,7 @@ public class Mobibot extends PircBot
Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient()) + " ["
+ Utils.UTC_SDF.format(message.getReceived()) + ", ID: " + message.getId()
+ ", DELIVERED]",
- true
- );
+ true);
}
else
@@ -2509,8 +2501,7 @@ public class Mobibot extends PircBot
send(sender,
Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient()) + " ["
+ Utils.UTC_SDF.format(message.getQueued()) + ", ID: " + message.getId() + ", QUEUED]",
- true
- );
+ true);
}
send(sender, DOUBLE_INDENT + message.getMessage(), true);
@@ -2527,8 +2518,7 @@ public class Mobibot extends PircBot
send(sender,
DOUBLE_INDENT + Utils
.bold(getNick() + ": " + Commands.TELL_CMD + ' ' + Commands.TELL_DEL_CMD + " ')
- );
+ + Commands.TELL_ALL_CMD + '>'));
send(sender, "Messages are kept for " + Utils.bold(tellMaxDays) + " days.");
}
}
@@ -2789,8 +2779,7 @@ public class Mobibot extends PircBot
send(sender,
"To view more, try: " + Utils
.bold(getNick() + ": " + Commands.VIEW_CMD + ' ' + (i + 1) + ' ' + lcArgs),
- isPrivate
- );
+ isPrivate);
break;
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/Quote.java b/src/main/java/net/thauvin/erik/mobibot/Quote.java
index b626988..4838d48 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Quote.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Quote.java
@@ -1,7 +1,7 @@
/*
- * @(#)Quote.java
+ * Quote.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import org.jibble.pircbot.Colors;
diff --git a/src/main/java/net/thauvin/erik/mobibot/ReleaseInfo.java b/src/main/java/net/thauvin/erik/mobibot/ReleaseInfo.java
index 7caf1ec..d17fb03 100644
--- a/src/main/java/net/thauvin/erik/mobibot/ReleaseInfo.java
+++ b/src/main/java/net/thauvin/erik/mobibot/ReleaseInfo.java
@@ -1,7 +1,7 @@
/*
- * @(#)ReleaseInfo.java
+ * ReleaseInfo.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -82,6 +82,16 @@ public class ReleaseInfo
return buildDate;
}
+ /**
+ * Get buildNumber (set during build process to 0).
+ *
+ * @return int buildNumber
+ */
+ public static int getBuildNumber()
+ {
+ return 0;
+ }
+
/**
* Get project (set during build process to "mobibot").
*
@@ -102,14 +112,4 @@ public class ReleaseInfo
return version;
}
- /**
- * Get buildNumber (set during build process to 0).
- *
- * @return int buildNumber
- */
- public static int getBuildNumber()
- {
- return 0;
- }
-
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/StockQuote.java b/src/main/java/net/thauvin/erik/mobibot/StockQuote.java
index 50d57e6..a2bd7fa 100644
--- a/src/main/java/net/thauvin/erik/mobibot/StockQuote.java
+++ b/src/main/java/net/thauvin/erik/mobibot/StockQuote.java
@@ -1,7 +1,7 @@
/*
- * @(#)StockQuote.java
+ * StockQuote.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import com.Ostermiller.util.CSVParser;
diff --git a/src/main/java/net/thauvin/erik/mobibot/SwingWorker.java b/src/main/java/net/thauvin/erik/mobibot/SwingWorker.java
index c99a9ab..e19c1d2 100644
--- a/src/main/java/net/thauvin/erik/mobibot/SwingWorker.java
+++ b/src/main/java/net/thauvin/erik/mobibot/SwingWorker.java
@@ -4,20 +4,20 @@ import javax.swing.*;
/**
* This is the 3rd version of SwingWorker (also known as SwingWorker 3), an abstract class that you subclass to perform
- * GUI-related work in a dedicated thread. For instructions on and examples of using this class, see:
- *
+ * GUI-related work in a dedicated thread. For instructions on and examples of using this class, see:
+ *
- * Note that the API changed slightly in the 3rd version: You must now invoke start() on the SwingWorker after creating
- * it.
+ *
+ * Note that the API changed slightly in the 3rd version:
+ * You must now invoke start() on the SwingWorker after creating it.
*/
@SuppressWarnings("ALL")
public abstract class SwingWorker
{
- private Object value; // see getValue(), setValue()
-
private ThreadVar threadVar;
+ private Object value; // see getValue(), setValue()
+
/**
* Start a thread that will call the construct method and then exit.
*/
@@ -67,19 +67,6 @@ public abstract class SwingWorker
*/
public abstract Object construct();
- /**
- * A new method that interrupts the worker thread. Call this method to force the worker to stop what it's doing.
- */
- public void interrupt()
- {
- Thread t = threadVar.get();
- if (t != null)
- {
- t.interrupt();
- }
- threadVar.clear();
- }
-
/**
* Return the value created by the construct method. Returns null if either the constructing thread or
* the current thread was interrupted before a value was produced.
@@ -127,6 +114,19 @@ public abstract class SwingWorker
value = x;
}
+ /**
+ * A new method that interrupts the worker thread. Call this method to force the worker to stop what it's doing.
+ */
+ public void interrupt()
+ {
+ Thread t = threadVar.get();
+ if (t != null)
+ {
+ t.interrupt();
+ }
+ threadVar.clear();
+ }
+
/**
* Start the worker thread.
*/
@@ -151,14 +151,14 @@ public abstract class SwingWorker
thread = t;
}
- synchronized Thread get()
- {
- return thread;
- }
-
synchronized void clear()
{
thread = null;
}
+
+ synchronized Thread get()
+ {
+ return thread;
+ }
}
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/TellMessage.java b/src/main/java/net/thauvin/erik/mobibot/TellMessage.java
index 77ebdf9..48b3cbd 100644
--- a/src/main/java/net/thauvin/erik/mobibot/TellMessage.java
+++ b/src/main/java/net/thauvin/erik/mobibot/TellMessage.java
@@ -1,7 +1,7 @@
/*
- * @(#)TellMessage.java
+ * TellMessage.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import java.io.Serializable;
@@ -47,23 +46,24 @@ import java.util.Date;
*/
public class TellMessage implements Serializable
{
+ @SuppressWarnings({"UnusedDeclaration"})
private static final long serialVersionUID = 1L;
- private final String sender;
-
- private final String recipient;
-
- private final String message;
-
private final String id;
+ private final String message;
+
final private Date queued;
- private Date received;
+ private final String recipient;
+
+ private final String sender;
+
+ private boolean isNotified;
private boolean isReceived;
- private boolean isNotified;
+ private Date received;
/**
* Create a new message.
diff --git a/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java b/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java
index 9e9b4aa..d6b9b2b 100644
--- a/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java
+++ b/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java
@@ -1,7 +1,7 @@
/*
- * @(#)TellMessagesMgr.java
+ * TellMessagesMgr.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import org.apache.commons.logging.impl.Log4JLogger;
@@ -54,7 +53,7 @@ public class TellMessagesMgr
/**
* Disables the default constructor.
*
- * @throws UnsupportedOperationException if an error occurred. if the constructor is called.
+ * @throws UnsupportedOperationException If the constructor is called.
*/
private TellMessagesMgr()
throws UnsupportedOperationException
@@ -62,6 +61,35 @@ public class TellMessagesMgr
throw new UnsupportedOperationException("Illegal constructor call.");
}
+ /**
+ * Cleans the messages queue
+ *
+ * @param tellMessages The messages list.
+ * @param tellMaxDays The maximum number of days to keep messages for.
+ *
+ * @return True if the queue was cleaned.
+ */
+ public static boolean cleanTellMessages(List tellMessages, int tellMaxDays)
+ {
+ final Calendar maxDate = Calendar.getInstance();
+ final Date today = new Date();
+ boolean cleaned = false;
+
+ for (final TellMessage message : tellMessages)
+ {
+ maxDate.setTime(message.getQueued());
+ maxDate.add(Calendar.DATE, tellMaxDays);
+
+ if (maxDate.getTime().before(today))
+ {
+ tellMessages.remove(message);
+ cleaned = true;
+ }
+ }
+
+ return cleaned;
+ }
+
/**
* Loads the messages.
*
@@ -79,7 +107,6 @@ public class TellMessagesMgr
try
{
-
if (logger.isDebugEnabled())
{
logger.debug("Loading the messages.");
@@ -140,27 +167,4 @@ public class TellMessagesMgr
logger.error("Unable to save messages queue.", e);
}
}
-
- /**
- * Cleans the messages queue
- *
- * @param tellMessages The messages list.
- * @param tellMaxDays The maximum number of days to keep messages for.
- */
- public static void cleanTellMessages(List tellMessages, int tellMaxDays)
- {
- final Calendar maxDate = Calendar.getInstance();
- final Date today = new Date();
-
- for (final TellMessage message : tellMessages)
- {
- maxDate.setTime(message.getQueued());
- maxDate.add(Calendar.DATE, tellMaxDays);
-
- if (maxDate.getTime().before(today))
- {
- tellMessages.remove(message);
- }
- }
- }
}
\ No newline at end of file
diff --git a/src/main/java/net/thauvin/erik/mobibot/Twitter.java b/src/main/java/net/thauvin/erik/mobibot/Twitter.java
index 049a15f..63aa811 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Twitter.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Twitter.java
@@ -1,7 +1,7 @@
/*
- * @(#)Twitter.java
+ * Twitter.java
*
- * Copyright (c) 2004-2014, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
package net.thauvin.erik.mobibot;
import twitter4j.Status;
@@ -47,26 +46,6 @@ import twitter4j.conf.ConfigurationBuilder;
*/
public class Twitter implements Runnable
{
- /**
- * The bot.
- */
- private final Mobibot bot;
-
- /**
- * The Twitter consumer secret.
- */
- private final String consumerSecret;
-
- /**
- * The Twitter consumer key.
- */
- private final String consumerKey;
-
- /**
- * The Twitter message.
- */
- private final String message;
-
/**
* The Twitter access token.
*/
@@ -77,6 +56,26 @@ public class Twitter implements Runnable
*/
private final String accessTokenSecret;
+ /**
+ * The bot.
+ */
+ private final Mobibot bot;
+
+ /**
+ * The Twitter consumer key.
+ */
+ private final String consumerKey;
+
+ /**
+ * The Twitter consumer secret.
+ */
+ private final String consumerSecret;
+
+ /**
+ * The Twitter message.
+ */
+ private final String message;
+
/**
* The nick of the person who sent the message.
*/
@@ -122,8 +121,7 @@ public class Twitter implements Runnable
bot.send(sender,
"You message was posted to http://twitter.com/" + twitter.getScreenName() + "/statuses/" + status
- .getId()
- );
+ .getId());
}
catch (Exception e)
{
diff --git a/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java b/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
index 3fa40a7..04fcf26 100644
--- a/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
+++ b/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
@@ -9,15 +9,9 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
- * The TwitterOAuth class.
- *