Added Javascript encoding/decoding to joke module.

This commit is contained in:
Erik C. Thauvin 2015-08-31 12:36:40 -07:00
parent b7e6cbe8ca
commit 12e3a57836
6 changed files with 474 additions and 464 deletions

View file

@ -1,5 +1,5 @@
/*
* Quote.java
* Joke.java
*
* Copyright (c) 2004-2015, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
@ -52,10 +52,9 @@ public class Joke implements Runnable
{
/**
* The I Heart Quotes URL.
* The ICNDB URL.
*/
private static final String JOKE_URL =
"http://api.icndb.com/jokes/random";
private static final String JOKE_URL = "http://api.icndb.com/jokes/random?escape=javascript";
/**
* The bot's instance.
@ -100,7 +99,9 @@ public class Joke implements Runnable
final JSONObject json = new JSONObject(sb.toString());
bot.send(bot.getChannel(), Colors.CYAN + json.getJSONObject("value").get("joke") + Colors.CYAN);
bot.send(bot.getChannel(),
Colors.CYAN + json.getJSONObject("value").get("joke").toString().replaceAll("\\'", "'")
.replaceAll("\\\"", "\"") + Colors.CYAN);
reader.close();
}

View file

@ -1,5 +1,5 @@
/* Created by JReleaseInfo AntTask from Open Source Competence Group */
/* Creation date Sat Aug 29 12:08:20 PDT 2015 */
/* Creation date Mon Aug 31 12:19:55 PDT 2015 */
package net.thauvin.erik.mobibot;
import java.util.Date;
@ -20,11 +20,11 @@ public class ReleaseInfo {
}
/** buildDate (set during build process to 1440875300470L). */
private static final Date buildDate = new Date(1440875300470L);
/** buildDate (set during build process to 1441048795735L). */
private static final Date buildDate = new Date(1441048795735L);
/**
* Get buildDate (set during build process to Sat Aug 29 12:08:20 PDT 2015).
* Get buildDate (set during build process to Mon Aug 31 12:19:55 PDT 2015).
* @return Date buildDate
*/
public static Date getBuildDate() { return buildDate; }