Added user-agent to jsoup posted link title query.

More code & comments cleanup.
This commit is contained in:
Erik C. Thauvin 2014-04-30 02:36:59 -07:00
parent 85ed19f259
commit b720927061
21 changed files with 544 additions and 604 deletions

View file

@ -67,6 +67,10 @@ compileJava {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
} }
javadoc {
options.tags = ['created']
}
jar { jar {
manifest.attributes('Main-Class': mainClassName, manifest.attributes('Main-Class': mainClassName,
'Class-Path': '. ./lib/' + configurations.compile.collect { it.getName() }.join(' ./lib/')) 'Class-Path': '. ./lib/' + configurations.compile.collect { it.getName() }.join(' ./lib/'))

File diff suppressed because it is too large Load diff

View file

@ -46,7 +46,7 @@ import java.text.NumberFormat;
import java.util.*; import java.util.*;
/** /**
* Converts various currencies. * Processes the {@link Commands#CURRENCY_CMD} command.
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 11, 2004 * @created Feb 11, 2004
@ -85,16 +85,18 @@ public class CurrencyConverter implements Runnable
private String pubDate = ""; private String pubDate = "";
/** /**
* Creates a new CurrencyConverter object. * Creates a new {@link CurrencyConverter} instance.
* *
* @param bot The bot. * @param bot The bot's instance.
*/ */
public CurrencyConverter(Mobibot bot) public CurrencyConverter(Mobibot bot)
{ {
this.bot = bot; this.bot = bot;
} }
// Converts specified currencies. /**
* Converts the specified currencies.
*/
public final void run() public final void run()
{ {
if (Utils.isValidString(sender) && Utils.isValidString(query)) if (Utils.isValidString(sender) && Utils.isValidString(query))
@ -215,7 +217,7 @@ public class CurrencyConverter implements Runnable
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
* @param query The currency query. * @param query The currency query.
*/ */
public void setQuery(String sender, String query) public synchronized void setQuery(String sender, String query)
{ {
this.query = query; this.query = query;
this.sender = sender; this.sender = sender;

View file

@ -51,7 +51,7 @@ public class DeliciousPoster
private final String ircServer; private final String ircServer;
/** /**
* Creates a new DeliciousPoster instance. * Creates a new {@link DeliciousPoster} instance.
* *
* @param username The del.icio.us username. * @param username The del.icio.us username.
* @param password The del.icio.us password. * @param password The del.icio.us password.

View file

@ -36,7 +36,7 @@ package net.thauvin.erik.mobibot;
import java.util.Random; import java.util.Random;
/** /**
* The {@link net.thauvin.erik.mobibot.Commands#DICE_CMD} command * Processes the {@link Commands#DICE_CMD} command.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-28 * @created 2014-04-28
@ -56,9 +56,9 @@ public class Dice
} }
/** /**
* Rolls the dice * Rolls the dice.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The sender's nickname. * @param sender The sender's nickname.
*/ */
public static void roll(Mobibot bot, String sender) public static void roll(Mobibot bot, String sender)

View file

@ -214,6 +214,9 @@ public class EntriesMgr
/** /**
* Saves the entries. * Saves the entries.
* *
* @param bot The bot object.
* @param entries The entries array.
* @param history The history array.
* @param isDayBackup Set the true if the daily backup file should also be created. * @param isDayBackup Set the true if the daily backup file should also be created.
*/ */
public static void saveEntries(Mobibot bot, List<EntryLink> entries, List<String> history, boolean isDayBackup) public static void saveEntries(Mobibot bot, List<EntryLink> entries, List<String> history, boolean isDayBackup)

View file

@ -37,10 +37,10 @@ package net.thauvin.erik.mobibot;
import com.sun.syndication.feed.synd.SyndCategoryImpl; import com.sun.syndication.feed.synd.SyndCategoryImpl;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/** /**
* The class used to store link entries. * The class used to store link entries.
@ -57,10 +57,10 @@ public class EntryLink implements Serializable
static final long serialVersionUID = 3676245542270899086L; static final long serialVersionUID = 3676245542270899086L;
// The link's comments // The link's comments
private final List<EntryComment> comments = new ArrayList<EntryComment>(0); private final List<EntryComment> comments = new CopyOnWriteArrayList<EntryComment>();
// The tags/categories // The tags/categories
private final List<SyndCategoryImpl> tags = new ArrayList<SyndCategoryImpl>(0); private final List<SyndCategoryImpl> tags = new CopyOnWriteArrayList<SyndCategoryImpl>();
// The channel // The channel
private String channel = ""; private String channel = "";
@ -106,7 +106,7 @@ public class EntryLink implements Serializable
* *
* @param tags The space-delimited tags. * @param tags The space-delimited tags.
*/ */
public final synchronized void setTags(String tags) public final void setTags(String tags)
{ {
if (tags != null) if (tags != null)
{ {
@ -185,7 +185,7 @@ public class EntryLink implements Serializable
* *
* @return The total number of comments for this entry. * @return The total number of comments for this entry.
*/ */
public final synchronized int addComment(String comment, String nick) public final int addComment(String comment, String nick)
{ {
comments.add(new EntryComment(comment, nick)); comments.add(new EntryComment(comment, nick));
@ -197,7 +197,7 @@ public class EntryLink implements Serializable
* *
* @param index The index of the comment to delete. * @param index The index of the comment to delete.
*/ */
public final synchronized void deleteComment(int index) public final void deleteComment(int index)
{ {
if (index < comments.size()) if (index < comments.size())
{ {
@ -210,7 +210,7 @@ public class EntryLink implements Serializable
* *
* @return The channel * @return The channel
*/ */
public final synchronized String getChannel() public final String getChannel()
{ {
return channel; return channel;
} }
@ -221,7 +221,7 @@ public class EntryLink implements Serializable
* @param channel The channel. * @param channel The channel.
*/ */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public final synchronized void setChannel(String channel) public final void setChannel(String channel)
{ {
this.channel = channel; this.channel = channel;
} }
@ -233,7 +233,7 @@ public class EntryLink implements Serializable
* *
* @return The specific comment. * @return The specific comment.
*/ */
public final synchronized EntryComment getComment(int index) public final EntryComment getComment(int index)
{ {
return (comments.get(index)); return (comments.get(index));
} }
@ -243,7 +243,7 @@ public class EntryLink implements Serializable
* *
* @return The comments. * @return The comments.
*/ */
public final synchronized EntryComment[] getComments() public final EntryComment[] getComments()
{ {
return (comments.toArray(new EntryComment[comments.size()])); return (comments.toArray(new EntryComment[comments.size()]));
} }
@ -253,7 +253,7 @@ public class EntryLink implements Serializable
* *
* @return The count of comments. * @return The count of comments.
*/ */
public final synchronized int getCommentsCount() public final int getCommentsCount()
{ {
return comments.size(); return comments.size();
} }
@ -263,7 +263,7 @@ public class EntryLink implements Serializable
* *
* @return The date. * @return The date.
*/ */
public final synchronized Date getDate() public final Date getDate()
{ {
return date; return date;
} }
@ -273,7 +273,7 @@ public class EntryLink implements Serializable
* *
* @return The tags as a comma-delimited string. * @return The tags as a comma-delimited string.
*/ */
public final synchronized String getDeliciousTags() public final String getDeliciousTags()
{ {
final StringBuilder tags = new StringBuilder(nick); final StringBuilder tags = new StringBuilder(nick);
@ -291,7 +291,7 @@ public class EntryLink implements Serializable
* *
* @return The link. * @return The link.
*/ */
public final synchronized String getLink() public final String getLink()
{ {
return link; return link;
} }
@ -301,7 +301,7 @@ public class EntryLink implements Serializable
* *
* @param link The new link. * @param link The new link.
*/ */
public final synchronized void setLink(String link) public final void setLink(String link)
{ {
this.link = link; this.link = link;
} }
@ -311,7 +311,7 @@ public class EntryLink implements Serializable
* *
* @return The login; * @return The login;
*/ */
public final synchronized String getLogin() public final String getLogin()
{ {
return login; return login;
} }
@ -322,7 +322,7 @@ public class EntryLink implements Serializable
* @param login The new login. * @param login The new login.
*/ */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public final synchronized void setLogin(String login) public final void setLogin(String login)
{ {
this.login = login; this.login = login;
} }
@ -332,7 +332,7 @@ public class EntryLink implements Serializable
* *
* @return The nickname. * @return The nickname.
*/ */
public final synchronized String getNick() public final String getNick()
{ {
return nick; return nick;
} }
@ -342,7 +342,7 @@ public class EntryLink implements Serializable
* *
* @param nick The new nickname. * @param nick The new nickname.
*/ */
public final synchronized void setNick(String nick) public final void setNick(String nick)
{ {
this.nick = nick; this.nick = nick;
} }
@ -352,7 +352,7 @@ public class EntryLink implements Serializable
* *
* @return The tags. * @return The tags.
*/ */
public final synchronized List getTags() public final List getTags()
{ {
return tags; return tags;
} }
@ -362,7 +362,7 @@ public class EntryLink implements Serializable
* *
* @param tags The tags. * @param tags The tags.
*/ */
final synchronized void setTags(List<SyndCategoryImpl> tags) final void setTags(List<SyndCategoryImpl> tags)
{ {
this.tags.addAll(tags); this.tags.addAll(tags);
} }
@ -372,7 +372,7 @@ public class EntryLink implements Serializable
* *
* @return The title. * @return The title.
*/ */
public final synchronized String getTitle() public final String getTitle()
{ {
return title; return title;
} }
@ -382,7 +382,7 @@ public class EntryLink implements Serializable
* *
* @param title The new title. * @param title The new title.
*/ */
public final synchronized void setTitle(String title) public final void setTitle(String title)
{ {
this.title = title; this.title = title;
} }
@ -392,7 +392,7 @@ public class EntryLink implements Serializable
* *
* @return true if there are comments, false otherwise. * @return true if there are comments, false otherwise.
*/ */
public final synchronized boolean hasComments() public final boolean hasComments()
{ {
return (!comments.isEmpty()); return (!comments.isEmpty());
} }
@ -402,7 +402,7 @@ public class EntryLink implements Serializable
* *
* @return true if there are tags, false otherwise. * @return true if there are tags, false otherwise.
*/ */
public final synchronized boolean hasTags() public final boolean hasTags()
{ {
return (!tags.isEmpty()); return (!tags.isEmpty());
} }
@ -414,7 +414,7 @@ public class EntryLink implements Serializable
* @param comment The actual comment. * @param comment The actual comment.
* @param nick The nickname of the author of the comment. * @param nick The nickname of the author of the comment.
*/ */
public final synchronized void setComment(int index, String comment, String nick) public final void setComment(int index, String comment, String nick)
{ {
if (index < comments.size()) if (index < comments.size())
{ {

View file

@ -79,9 +79,9 @@ public class FeedReader implements Runnable
private final String url; private final String url;
/** /**
* Creates a new FeedReader object. * Creates a new {@link FeedReader} instance.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
* @param url The URL to fetch. * @param url The URL to fetch.
*/ */

View file

@ -44,7 +44,7 @@ import java.net.URLConnection;
import java.net.URLEncoder; import java.net.URLEncoder;
/** /**
* Performs a Google search or spell checking query. * Processes the {@link Commands#GOOGLE_CMD} command.
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 7, 2004 * @created Feb 7, 2004
@ -73,9 +73,9 @@ public class GoogleSearch implements Runnable
private final String sender; private final String sender;
/** /**
* Creates a new GoogleSearch object. * Creates a new {@link GoogleSearch} instance.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
* @param query The Google query * @param query The Google query
*/ */
@ -87,7 +87,7 @@ public class GoogleSearch implements Runnable
} }
/** /**
* Main processing method. * Searches Google.
*/ */
public final void run() public final void run()
{ {

View file

@ -41,7 +41,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
/** /**
* Performs a DNS lookup query. * Processes the {@link Commands#LOOKUP_CMD} command.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-26 * @created 2014-04-26

View file

@ -176,7 +176,7 @@ public class Mobibot extends PircBot
private final List<String> recap = new ArrayList<String>(0); private final List<String> recap = new ArrayList<String>(0);
/** /**
* The {@link Commands#TELL_CMD} messages queue. * Processes the {@link Commands#TELL_CMD} messages queue.
*/ */
private final List<TellMessage> tellMessages = new CopyOnWriteArrayList<TellMessage>(); private final List<TellMessage> tellMessages = new CopyOnWriteArrayList<TellMessage>();
@ -311,7 +311,7 @@ public class Mobibot extends PircBot
private String weblogUrl = ""; private String weblogUrl = "";
/** /**
* Creates a new Mobibot object. * Creates a new {@link Mobibot} instance.
* *
* @param server The server. * @param server The server.
* @param port The port. * @param port The port.
@ -346,6 +346,11 @@ public class Mobibot extends PircBot
{ {
today = EntriesMgr.loadEntries(this.logsDir + EntriesMgr.CURRENT_XML, this.channel, entries); today = EntriesMgr.loadEntries(this.logsDir + EntriesMgr.CURRENT_XML, this.channel, entries);
if (logger.isDebugEnabled())
{
logger.debug("Last feed: " + today);
}
if (!Utils.today().equals(today)) if (!Utils.today().equals(today))
{ {
entries.clear(); entries.clear();
@ -787,6 +792,11 @@ public class Mobibot extends PircBot
*/ */
private void cleanTellMessages() private void cleanTellMessages()
{ {
if (logger.isDebugEnabled())
{
logger.debug("Cleaning the messages.");
}
TellMessagesMgr.cleanTellMessages(tellMessages, tellMaxDays); TellMessagesMgr.cleanTellMessages(tellMessages, tellMaxDays);
} }
@ -876,13 +886,16 @@ public class Mobibot extends PircBot
{ {
EntryLink entry; EntryLink entry;
for (int i = 0; i < entries.size(); i++) synchronized (entries)
{ {
entry = entries.get(i); for (int i = 0; i < entries.size(); i++)
if (link.equals(entry.getLink()))
{ {
return i; entry = entries.get(i);
if (link.equals(entry.getLink()))
{
return i;
}
} }
} }
@ -896,7 +909,7 @@ public class Mobibot extends PircBot
*/ */
public final String getBacklogsUrl() public final String getBacklogsUrl()
{ {
return backLogsUrl; return this.backLogsUrl;
} }
/** /**
@ -914,9 +927,9 @@ public class Mobibot extends PircBot
* *
* @return The feed info cache. * @return The feed info cache.
*/ */
public final synchronized FeedFetcherCache getFeedInfoCache() public final FeedFetcherCache getFeedInfoCache()
{ {
return feedInfoCache; return this.feedInfoCache;
} }
/** /**
@ -926,7 +939,7 @@ public class Mobibot extends PircBot
*/ */
public final String getIrcServer() public final String getIrcServer()
{ {
return ircServer; return this.ircServer;
} }
/** /**
@ -936,7 +949,7 @@ public class Mobibot extends PircBot
*/ */
public final String getLogsDir() public final String getLogsDir()
{ {
return logsDir; return this.logsDir;
} }
/** /**
@ -973,9 +986,9 @@ public class Mobibot extends PircBot
* *
* @return Today's date. * @return Today's date.
*/ */
public synchronized String getToday() public String getToday()
{ {
return today; return this.today;
} }
/** /**
@ -985,7 +998,7 @@ public class Mobibot extends PircBot
*/ */
public final String getWeblogUrl() public final String getWeblogUrl()
{ {
return weblogUrl; return this.weblogUrl;
} }
/** /**
@ -1198,7 +1211,7 @@ public class Mobibot extends PircBot
send(sender, "To view queued and sent messages:"); send(sender, "To view queued and sent messages:");
send(sender, DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.TELL_CMD + ' ' + Commands.VIEW_CMD)); send(sender, DOUBLE_INDENT + Utils.bold(getNick() + ": " + Commands.TELL_CMD + ' ' + Commands.VIEW_CMD));
send(sender, "Messages are kept for around " + Utils.bold(tellMaxDays) + " days."); send(sender, "Messages are kept for " + Utils.bold(tellMaxDays) + " days.");
} }
else else
{ {
@ -1362,6 +1375,7 @@ public class Mobibot extends PircBot
timeInSeconds -= (hours * 3600L); timeInSeconds -= (hours * 3600L);
final long minutes = timeInSeconds / 60L; final long minutes = timeInSeconds / 60L;
send(sender, send(sender,
"Uptime: " + days + " day(s) " + hours + " hour(s) " + minutes + " minute(s) [Entries: " + entries.size() "Uptime: " + days + " day(s) " + hours + " hour(s) " + minutes + " minute(s) [Entries: " + entries.size()
+ (isTellEnabled() && isOp(sender) ? ", Messages: " + tellMessages.size() : "") + ']', + (isTellEnabled() && isOp(sender) ? ", Messages: " + tellMessages.size() : "") + ']',
@ -1565,7 +1579,7 @@ public class Mobibot extends PircBot
if (dupIndex == -1) if (dupIndex == -1)
{ {
if (!Utils.today().equals(getToday())) if (!Utils.today().equals(today))
{ {
isBackup = true; isBackup = true;
saveEntries(true); saveEntries(true);
@ -1600,7 +1614,7 @@ public class Mobibot extends PircBot
{ {
try try
{ {
final Document html = Jsoup.connect(link).get(); final Document html = Jsoup.connect(link).userAgent("Mozilla").get();
final String htmlTitle = html.title(); final String htmlTitle = html.title();
if (Utils.isValidString(htmlTitle)) if (Utils.isValidString(htmlTitle))
@ -1968,7 +1982,7 @@ public class Mobibot extends PircBot
} }
} }
} }
// L1.1:<comment> // L1.1:<command>
else if (message.matches(Commands.LINK_CMD + "[0-9]+\\.[0-9]+:.*")) else if (message.matches(Commands.LINK_CMD + "[0-9]+\\.[0-9]+:.*"))
{ {
isCommand = true; isCommand = true;
@ -2503,7 +2517,7 @@ public class Mobibot extends PircBot
.bold(getNick() + ": " + Commands.TELL_CMD + ' ' + Commands.TELL_DEL_CMD + " <id|" .bold(getNick() + ": " + Commands.TELL_CMD + ' ' + Commands.TELL_DEL_CMD + " <id|"
+ Commands.TELL_ALL_CMD + '>') + Commands.TELL_ALL_CMD + '>')
); );
send(sender, "Messages are kept for around " + Utils.bold(tellMaxDays) + " days."); send(sender, "Messages are kept for " + Utils.bold(tellMaxDays) + " days.");
} }
} }
} }

View file

@ -43,7 +43,7 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
/** /**
* Retrieve quote from <a href="iheartquotes.com">I Heart Quotes</a> * Processes the {@link Commands#QUOTE_CMD} command.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-20 * @created 2014-04-20
@ -59,7 +59,7 @@ public class Quote implements Runnable
"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"; "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";
/** /**
* The bot. * The bot's instance.
*/ */
private final Mobibot bot; private final Mobibot bot;
@ -69,9 +69,9 @@ public class Quote implements Runnable
private final String sender; private final String sender;
/** /**
* Creates a new StockQuote object. * Creates a new {@link StockQuote} instance.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
*/ */
public Quote(Mobibot bot, String sender) public Quote(Mobibot bot, String sender)
@ -81,7 +81,7 @@ public class Quote implements Runnable
} }
/** /**
* Returns a random quote. * Returns a random quote from <a href="http://iheartquotes.com/">I Heart Quote</a>
*/ */
public final void run() public final void run()
{ {

View file

@ -41,7 +41,7 @@ import org.apache.commons.httpclient.methods.GetMethod;
import java.io.IOException; import java.io.IOException;
/** /**
* Retrieves a stock quote from Yahoo!. * Processes the {@link Commands#STOCK_CMD} command.
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 7, 2004 * @created Feb 7, 2004
@ -70,9 +70,9 @@ public class StockQuote implements Runnable
private final String symbol; private final String symbol;
/** /**
* Creates a new StockQuote object. * Creates a new {@link StockQuote} instance.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
* @param symbol The stock symbol. * @param symbol The stock symbol.
*/ */
@ -84,7 +84,7 @@ public class StockQuote implements Runnable
} }
/** /**
* Returns the specified stock quote. * Returns the specified stock quote from Yahoo!
*/ */
public final void run() public final void run()
{ {

View file

@ -5,9 +5,9 @@ import javax.swing.*;
/** /**
* This is the 3rd version of SwingWorker (also known as SwingWorker 3), an abstract class that you subclass to perform * 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:
* <p/> * <p>
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html * http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
* <p/> * </p>
* Note that the API changed slightly in the 3rd version: You must now invoke start() on the SwingWorker after creating * Note that the API changed slightly in the 3rd version: You must now invoke start() on the SwingWorker after creating
* it. * it.
*/ */
@ -62,6 +62,8 @@ public abstract class SwingWorker
/** /**
* Compute the value to be returned by the <code>get</code> method. * Compute the value to be returned by the <code>get</code> method.
*
* @return The computed value.
*/ */
public abstract Object construct(); public abstract Object construct();
@ -107,6 +109,8 @@ public abstract class SwingWorker
/** /**
* Get the value produced by the worker thread, or null if it hasn't been constructed yet. * Get the value produced by the worker thread, or null if it hasn't been constructed yet.
*
* @return The value.
*/ */
protected synchronized Object getValue() protected synchronized Object getValue()
{ {
@ -115,6 +119,8 @@ public abstract class SwingWorker
/** /**
* Set the value produced by worker thread * Set the value produced by worker thread
*
* @param x The object.
*/ */
private synchronized void setValue(Object x) private synchronized void setValue(Object x)
{ {

View file

@ -83,61 +83,121 @@ public class TellMessage implements Serializable
} }
/**
* Returns the message id.
*
* @return The message id.
*/
public String getId() public String getId()
{ {
return this.id; return this.id;
} }
/**
* Returns the message text.
*
* @return The text of the message.
*/
public String getMessage() public String getMessage()
{ {
return message; return message;
} }
/**
* Returns the state of the queue flag.
*
* @return <code>true</code> if the message is queued.
*/
public Date getQueued() public Date getQueued()
{ {
return queued; return queued;
} }
/**
* Returns the state of the received flag.
*
* @return <code>true</code> if the message has been received.
*/
public Date getReceived() public Date getReceived()
{ {
return received; return received;
} }
/**
* Returns the message's recipient.
*
* @return The recipient of the message.
*/
public String getRecipient() public String getRecipient()
{ {
return recipient; return recipient;
} }
/**
* Returns the message's sender.
*
* @return The sender of the message.
*/
public String getSender() public String getSender()
{ {
return sender; return sender;
} }
/**
* Matches the message sender or recipient.
*
* @param nick The nickname to match with.
*
* @return <code>true</code> if the nickname matches.
*/
public boolean isMatch(String nick) public boolean isMatch(String nick)
{ {
return (sender.equalsIgnoreCase(nick) || recipient.equalsIgnoreCase(nick)); return (sender.equalsIgnoreCase(nick) || recipient.equalsIgnoreCase(nick));
} }
/**
* Match the message ID.
*
* @param id The ID to match with.
*
* @return <code>true</code> if the id matches.
*/
public boolean isMatchId(String id) public boolean isMatchId(String id)
{ {
return this.id.equals(id); return this.id.equals(id);
} }
/**
* Returns the notification flag state.
*
* @return <code>true</code> if the sender has been notified.
*/
public boolean isNotified() public boolean isNotified()
{ {
return this.isNotified; return this.isNotified;
} }
/**
* Returns the received flag state.
*
* @return <code>true</code> if the message was received.
*/
public boolean isReceived() public boolean isReceived()
{ {
return this.isReceived; return this.isReceived;
} }
/**
* Sets the notified flag.
*/
public void setIsNotified() public void setIsNotified()
{ {
this.isNotified = true; this.isNotified = true;
} }
/**
* Sets the received flag.
*/
public void setIsReceived() public void setIsReceived()
{ {
this.received = Calendar.getInstance().getTime(); this.received = Calendar.getInstance().getTime();

View file

@ -80,6 +80,11 @@ public class TellMessagesMgr
try try
{ {
if (logger.isDebugEnabled())
{
logger.debug("Loading the messages.");
}
return ((List<TellMessage>) input.readObject()); return ((List<TellMessage>) input.readObject());
} }
finally finally
@ -118,6 +123,10 @@ public class TellMessagesMgr
try try
{ {
if (logger.isDebugEnabled())
{
logger.debug("Saving the messages.");
}
output.writeObject(messages); output.writeObject(messages);
} }
finally finally
@ -132,7 +141,10 @@ public class TellMessagesMgr
} }
/** /**
* Cleans the messages queue. * 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<TellMessage> tellMessages, int tellMaxDays) public static void cleanTellMessages(List<TellMessage> tellMessages, int tellMaxDays)
{ {

View file

@ -39,7 +39,7 @@ import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder; import twitter4j.conf.ConfigurationBuilder;
/** /**
* Inserts presence information into Twitter. * Processes the {@link Commands#TWITTER_CMD} command.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created Sept 10, 2008 * @created Sept 10, 2008
@ -83,9 +83,9 @@ public class Twitter implements Runnable
private final String sender; private final String sender;
/** /**
* Creates a new Twitter object. * Creates a new {@link Twitter} instance.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
* @param consumerKey The Twitter consumer key. * @param consumerKey The Twitter consumer key.
* @param consumerSecret The Twitter consumer secret. * @param consumerSecret The Twitter consumer secret.
@ -105,6 +105,9 @@ public class Twitter implements Runnable
this.sender = sender; this.sender = sender;
} }
/**
* Posts to twitter.
*/
public final void run() public final void run()
{ {
try try

View file

@ -10,12 +10,13 @@ import java.io.InputStreamReader;
/** /**
* The <code>TwitterOAuth</code> class. * The <code>TwitterOAuth</code> class.
* <p/> * <p>
* Go to <a href="http://twitter.com/oauth_clients/new">http://twitter.com/oauth_clients/new</a> to register your bot. * Go to <a href="http://twitter.com/oauth_clients/new">http://twitter.com/oauth_clients/new</a> to register your bot.
* </p>
* Then execute: * Then execute:
* <p/> * <p>
* <code>java -cp "mobibot.jar:lib/*" net.thauvin.erik.mobibot.TwitterOAuth <consumerKey> <consumerSecret></code> * <code>java -cp "mobibot.jar:lib/*" net.thauvin.erik.mobibot.TwitterOAuth &lt;consumerKey&gt; &lt;consumerSecret&gt;</code>
* <p/> * </p>
* and follow the prompts/instructions. * and follow the prompts/instructions.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>

View file

@ -36,7 +36,7 @@ package net.thauvin.erik.mobibot;
import java.util.Random; import java.util.Random;
/** /**
* The <code>War</code> class. * Processes the {@link Commands#WAR_CMD} command.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-28 * @created 2014-04-28
@ -69,7 +69,7 @@ public class War
/** /**
* Plays war. * Plays war.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The sender's nickname. * @param sender The sender's nickname.
*/ */
public static void play(Mobibot bot, String sender) public static void play(Mobibot bot, String sender)

View file

@ -42,7 +42,7 @@ import java.text.DecimalFormat;
import java.util.Date; import java.util.Date;
/** /**
* Fetches the weather data from a specific station ID. * Processes the {@link Commands#LOOKUP_CMD} command.
* *
* @author Erik C. Thauvin * @author Erik C. Thauvin
* @created Feb 7, 2004 * @created Feb 7, 2004
@ -81,9 +81,9 @@ public class Weather implements Runnable
private final boolean isPrivate; private final boolean isPrivate;
/** /**
* Creates a new Weather object. * Creates a new {@link Weather} instance.
* *
* @param bot The bot. * @param bot The bot's instance.
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
* @param station The station ID. * @param station The station ID.
* @param isPrivate Set to true is the response should be send as a private message. * @param isPrivate Set to true is the response should be send as a private message.
@ -97,7 +97,7 @@ public class Weather implements Runnable
} }
/** /**
* Main processing method. * Fetches the weather data from a specific station ID.
*/ */
public final void run() public final void run()
{ {

View file

@ -40,7 +40,7 @@ import java.util.TimeZone;
import java.util.TreeMap; import java.util.TreeMap;
/** /**
* Processes the {@link net.thauvin.erik.mobibot.Commands#TIME_CMD} command. * The {@link Commands#TIME_CMD} command.
* *
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a> * @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @created 2014-04-27 * @created 2014-04-27
@ -65,7 +65,7 @@ public class WorldTime
new SimpleDateFormat("'The time is 'HH:mm' on 'EEEE, d MMMM yyyy' in '"); new SimpleDateFormat("'The time is 'HH:mm' on 'EEEE, d MMMM yyyy' in '");
/** /**
* Creates a new time object. * Creates a new {@link WorldTime} instance.
*/ */
public WorldTime() public WorldTime()
{ {
@ -140,8 +140,9 @@ public class WorldTime
} }
/** /**
* Responds with the current time. * Responds with the current time in the specified timezone/country.
* *
* @param bot The bot instance.
* @param sender The nick of the person who sent the message. * @param sender The nick of the person who sent the message.
* @param args The time command arguments. * @param args The time command arguments.
* @param isPrivate Set to true is the response should be send as a private message. * @param isPrivate Set to true is the response should be send as a private message.