diff --git a/mobibot.iws b/mobibot.iws
index 142310f..8f5dd81 100644
--- a/mobibot.iws
+++ b/mobibot.iws
@@ -34,13 +34,10 @@
-
-
+
-
-
-
+
@@ -201,9 +198,11 @@
-
-
-
+
+
+
+
+
@@ -212,7 +211,7 @@
-
+
@@ -223,20 +222,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -245,9 +231,9 @@
-
+
-
+
@@ -258,20 +244,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -280,10 +253,9 @@
-
+
-
-
+
@@ -293,31 +265,28 @@
-
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
+
+
+
@@ -772,10 +741,12 @@
@@ -1543,46 +1514,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1611,6 +1542,7 @@
+
@@ -1693,7 +1625,46 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1806,7 +1777,7 @@
-
+
@@ -2419,11 +2390,12 @@
+
-
+
@@ -2447,7 +2419,7 @@
-
+
@@ -2461,8 +2433,7 @@
-
-
+
@@ -2499,6 +2470,7 @@
+
@@ -2648,10 +2620,7 @@
-
-
-
-
+
@@ -2931,17 +2900,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -2957,10 +2915,7 @@
-
-
-
-
+
@@ -2968,20 +2923,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -2989,30 +2931,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -3026,18 +2945,10 @@
-
-
-
-
-
-
-
-
-
+
@@ -3045,26 +2956,53 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/net/thauvin/erik/mobibot/Commands.java b/src/main/java/net/thauvin/erik/mobibot/Commands.java
index 9d8b08c..3c1a2bc 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Commands.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Commands.java
@@ -127,6 +127,11 @@ public class Commands
*/
public static final String INFO_CMD = "info";
+ /**
+ * The joke command.
+ */
+ public static final String JOKE_CMD = "joke";
+
/**
* The link command.
*/
@@ -167,11 +172,6 @@ public class Commands
*/
public static final String PROPS_ARG = "properties";
- /**
- * The quote command.
- */
- public static final String QUOTE_CMD = "quote";
-
/**
* The recap command.
*/
diff --git a/src/main/java/net/thauvin/erik/mobibot/Quote.java b/src/main/java/net/thauvin/erik/mobibot/Joke.java
similarity index 80%
rename from src/main/java/net/thauvin/erik/mobibot/Quote.java
rename to src/main/java/net/thauvin/erik/mobibot/Joke.java
index 4838d48..bb6776d 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Quote.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Joke.java
@@ -42,20 +42,20 @@ import java.net.URL;
import java.net.URLConnection;
/**
- * Processes the {@link Commands#QUOTE_CMD} command.
+ * Processes the {@link Commands#JOKE_CMD} command.
*
* @author Erik C. Thauvin
* @created 2014-04-20
* @since 1.0
*/
-public class Quote implements Runnable
+public class Joke implements Runnable
{
/**
* The I Heart Quotes URL.
*/
- private static final String QUOTE_URL =
- "http://www.iheartquotes.com/api/v1/random?format=json&max_lines=1&source=esr+humorix_misc+humorix_stories+joel_on_software+macintosh+math+mav_flame+osp_rules+paul_graham+prog_style+subversion";
+ private static final String JOKE_URL =
+ "http://api.icndb.com/jokes/random";
/**
* The bot's instance.
@@ -68,25 +68,25 @@ public class Quote implements Runnable
private final String sender;
/**
- * Creates a new {@link StockQuote} instance.
+ * Creates a new {@link Joke} instance.
*
* @param bot The bot's instance.
* @param sender The nick of the person who sent the message.
*/
- public Quote(Mobibot bot, String sender)
+ public Joke(Mobibot bot, String sender)
{
this.bot = bot;
this.sender = sender;
}
/**
- * Returns a random quote from I Heart Quote
+ * Returns a random joke from The Internet Chuck Norris Database
*/
public final void run()
{
try
{
- final URL url = new URL(QUOTE_URL);
+ final URL url = new URL(JOKE_URL);
final URLConnection conn = url.openConnection();
final StringBuilder sb = new StringBuilder();
@@ -100,13 +100,13 @@ public class Quote implements Runnable
final JSONObject json = new JSONObject(sb.toString());
- bot.send(bot.getChannel(), Colors.CYAN + json.getString("quote") + Colors.CYAN);
+ bot.send(bot.getChannel(), Colors.CYAN + json.getJSONObject("value").get("joke") + Colors.CYAN);
reader.close();
}
catch (Exception e)
{
- bot.getLogger().warn("Unable to retrieve random quote.", e);
+ bot.getLogger().warn("Unable to retrieve random joke.", e);
bot.send(sender, "An error has occurred: " + e.getMessage());
}
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
index c7e510d..d9c3dc3 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
@@ -1126,10 +1126,10 @@ public class Mobibot extends PircBot
send(sender, "For a listing of the supported countries:");
send(sender, DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.TIME_CMD));
}
- else if (lcTopic.endsWith(Commands.QUOTE_CMD))
+ else if (lcTopic.endsWith(Commands.JOKE_CMD))
{
- send(sender, "To retrieve a random quote:");
- send(sender, DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.QUOTE_CMD));
+ send(sender, "To retrieve a random joke:");
+ send(sender, DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.JOKE_CMD));
}
else if (lcTopic.endsWith(Commands.STOCK_CMD))
{
@@ -1212,7 +1212,9 @@ public class Mobibot extends PircBot
if (lcTopic.endsWith(Commands.CURRENCY_CMD))
{
send(sender, "For a listing of currency rates:");
- send(sender, DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.CURRENCY_CMD) + ' ' + Commands.CURRENCY_RATES_KEYWORD);
+ send(sender,
+ DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.CURRENCY_CMD) + ' '
+ + Commands.CURRENCY_RATES_KEYWORD);
send(sender, "For a listing of supported currencies:");
send(sender, DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.CURRENCY_CMD));
}
@@ -1251,10 +1253,10 @@ public class Mobibot extends PircBot
cmds.add(Commands.GOOGLE_CMD);
cmds.add(Commands.IGNORE_CMD);
cmds.add(Commands.INFO_CMD);
+ cmds.add(Commands.JOKE_CMD);
cmds.add(Commands.LOOKUP_CMD);
cmds.add(channel.substring(1));
cmds.add(Commands.HELP_POSTING_KEYWORD);
- cmds.add(Commands.QUOTE_CMD);
cmds.add(Commands.RECAP_CMD);
cmds.add(Commands.STOCK_CMD);
cmds.add(Commands.HELP_TAGS_KEYWORD);
@@ -1795,10 +1797,10 @@ public class Mobibot extends PircBot
{
stockResponse(sender, args);
}
- // mobibot: quote
- else if (cmd.startsWith(Commands.QUOTE_CMD))
+ // mobibot: joke
+ else if (cmd.startsWith(Commands.JOKE_CMD))
{
- new Thread(new Quote(this, sender)).start();
+ new Thread(new Joke(this, sender)).start();
}
// mobibot: calc
else if (cmd.startsWith(Commands.CALC_CMD))