diff --git a/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java b/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java
index 58ab1e0..bdd3309 100644
--- a/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java
+++ b/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java
@@ -4,28 +4,26 @@
*/
package net.thauvin.erik.mobibot;
-import java.time.*;
+import java.util.Date;
/**
* Provides semantic version information.
*
- * @author Semantic Version
- * Annotation Processor
+ * @author Semantic Version Annotation Processor
*/
public final class ReleaseInfo {
public final static String PRERELEASE_PREFIX = "-";
public final static String BUILDMETA_PREFIX = "+";
- public final static String PROJECT = "mobibot";
- public final static LocalDateTime BUILDDATE =
- LocalDateTime.ofInstant(Instant.ofEpochMilli(1529959364831L), ZoneId.systemDefault());
+ public final static String PROJECT = "";
+ public final static Date BUILDDATE = new Date(1531467929376L);
public final static int MAJOR = 0;
public final static int MINOR = 7;
- public final static int PATCH = 2;
+ public final static int PATCH = 3;
public final static String PRERELEASE = "beta";
- public final static String BUILDMETA = "030";
+ public final static String BUILDMETA = "1";
- /**
+ /**
* The full version string.
*
* Formatted as:
diff --git a/src/main/java/net/thauvin/erik/mobibot/Commands.java b/src/main/java/net/thauvin/erik/mobibot/Commands.java
index e9227fb..c5eef7b 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Commands.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Commands.java
@@ -160,7 +160,7 @@ final public class Commands {
* @throws UnsupportedOperationException If the constructor is called.
*/
private Commands()
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java b/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java
index 6d494c7..839d0c1 100644
--- a/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java
+++ b/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java
@@ -74,7 +74,7 @@ final class EntriesMgr {
* @throws UnsupportedOperationException If the constructor is called.
*/
private EntriesMgr()
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
@@ -141,13 +141,13 @@ final class EntriesMgr {
for (int i = items.size() - 1; i >= 0; i--) {
item = (SyndEntryImpl) items.get(i);
author = item.getAuthor()
- .substring(item.getAuthor().lastIndexOf('(') + 1, item.getAuthor().length() - 1);
+ .substring(item.getAuthor().lastIndexOf('(') + 1, item.getAuthor().length() - 1);
entry = new EntryLink(item.getLink(),
- item.getTitle(),
- author,
- channel,
- item.getPublishedDate(),
- item.getCategories());
+ item.getTitle(),
+ author,
+ channel,
+ item.getPublishedDate(),
+ item.getCategories());
description = item.getDescription();
comments = description.getValue().split("
");
@@ -209,8 +209,8 @@ final class EntriesMgr {
entry = entries.get(i);
buff = new StringBuffer(
- "Posted by " + entry.getNick() + " on " + entry.getChannel() + "");
+ "Posted by " + entry.getNick() + " on " + entry.getChannel() + "");
if (entry.getCommentsCount() > 0) {
buff.append("
");
@@ -236,7 +236,7 @@ final class EntriesMgr {
item.setTitle(entry.getTitle());
item.setPublishedDate(entry.getDate());
item.setAuthor(
- bot.getChannel().substring(1) + '@' + bot.getIrcServer() + " (" + entry.getNick() + ')');
+ bot.getChannel().substring(1) + '@' + bot.getIrcServer() + " (" + entry.getNick() + ')');
item.setCategories(entry.getTags());
items.add(item);
@@ -304,7 +304,7 @@ final class EntriesMgr {
bot.getLogger().warn("Unable to generate the backlogs feed. No property configured.");
}
}
- } catch (Exception e) {
+ } catch (FeedException | IOException e) {
bot.getLogger().warn("Unable to generate the entries feed.", e);
} finally {
try {
@@ -317,7 +317,7 @@ final class EntriesMgr {
}
} else {
bot.getLogger()
- .warn("Unable to generate the entries feed. At least one of the required property is missing.");
+ .warn("Unable to generate the entries feed. At least one of the required property is missing.");
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/mobibot/EntryLink.java b/src/main/java/net/thauvin/erik/mobibot/EntryLink.java
index 81d1fd3..ab2ecc9 100644
--- a/src/main/java/net/thauvin/erik/mobibot/EntryLink.java
+++ b/src/main/java/net/thauvin/erik/mobibot/EntryLink.java
@@ -120,7 +120,7 @@ public class EntryLink implements Serializable {
this.title = title;
this.nick = nick;
this.channel = channel;
- this.date = date;
+ this.date = new Date(date.getTime());
setTags(tags);
}
@@ -202,23 +202,7 @@ public class EntryLink implements Serializable {
* @return The date.
*/
public final Date getDate() {
- return date;
- }
-
- /**
- * Returns the tags formatted for pinboard.in
- *
- * @return The tags as a comma-delimited string.
- */
- public final String getPinboardTags() {
- final StringBuilder tags = new StringBuilder(nick);
-
- for (final Object tag : this.tags) {
- tags.append(',');
- tags.append(((SyndCategoryImpl) tag).getName());
- }
-
- return tags.toString();
+ return new Date(date.getTime());
}
/**
@@ -276,6 +260,22 @@ public class EntryLink implements Serializable {
this.nick = nick;
}
+ /**
+ * Returns the tags formatted for pinboard.in
+ *
+ * @return The tags as a comma-delimited string.
+ */
+ public final String getPinboardTags() {
+ final StringBuilder tags = new StringBuilder(nick);
+
+ for (final Object tag : this.tags) {
+ tags.append(',');
+ tags.append(((SyndCategoryImpl) tag).getName());
+ }
+
+ return tags.toString();
+ }
+
/**
* Returns the tags.
*
@@ -288,10 +288,44 @@ public class EntryLink implements Serializable {
/**
* Sets the tags.
*
- * @param tags The tags.
+ * @param tags The space-delimited tags.
*/
- private void setTags(final List tags) {
- this.tags.addAll(tags);
+ public final void setTags(final String tags) {
+ if (tags != null) {
+ final String[] parts = tags.replaceAll(", ", " ").replaceAll(",", " ").split(" ");
+
+ SyndCategoryImpl tag;
+ String part;
+ char mod;
+
+ for (final String rawPart : parts) {
+ part = rawPart.trim();
+
+ if (part.length() >= 2) {
+ tag = new SyndCategoryImpl();
+ tag.setName(part.substring(1).toLowerCase());
+
+ mod = part.charAt(0);
+
+ if (mod == '-') {
+ // Don't remove the channel tag, if any.
+ if (!tag.getName().equals(channel.substring(1))) {
+ this.tags.remove(tag);
+ }
+ } else if (mod == '+') {
+ if (!this.tags.contains(tag)) {
+ this.tags.add(tag);
+ }
+ } else {
+ tag.setName(part.trim().toLowerCase());
+
+ if (!this.tags.contains(tag)) {
+ this.tags.add(tag);
+ }
+ }
+ }
+ }
+ }
}
/**
@@ -346,44 +380,10 @@ public class EntryLink implements Serializable {
/**
* Sets the tags.
*
- * @param tags The space-delimited tags.
+ * @param tags The tags.
*/
- public final void setTags(final String tags) {
- if (tags != null) {
- final String[] parts = tags.replaceAll(", ", " ").replaceAll(",", " ").split(" ");
-
- SyndCategoryImpl tag;
- String part;
- char mod;
-
- for (final String rawPart : parts) {
- part = rawPart.trim();
-
- if (part.length() >= 2) {
- tag = new SyndCategoryImpl();
- tag.setName(part.substring(1).toLowerCase());
-
- mod = part.charAt(0);
-
- if (mod == '-') {
- // Don't remove the channel tag, if any.
- if (!tag.getName().equals(channel.substring(1))) {
- this.tags.remove(tag);
- }
- } else if (mod == '+') {
- if (!this.tags.contains(tag)) {
- this.tags.add(tag);
- }
- } else {
- tag.setName(part.trim().toLowerCase());
-
- if (!this.tags.contains(tag)) {
- this.tags.add(tag);
- }
- }
- }
- }
- }
+ private void setTags(final List tags) {
+ this.tags.addAll(tags);
}
/**
@@ -394,7 +394,7 @@ public class EntryLink implements Serializable {
public final String toString() {
return super.toString() + "[ channel -> '" + channel + '\'' + ", comments -> " + comments + ", date -> " + date
- + ", link -> '" + link + '\'' + ", login -> '" + login + '\'' + ", nick -> '" + nick + '\''
- + ", tags -> " + tags + ", title -> '" + title + '\'' + " ]";
+ + ", link -> '" + link + '\'' + ", login -> '" + login + '\'' + ", nick -> '" + nick + '\''
+ + ", tags -> " + tags + ", title -> '" + title + '\'' + " ]";
}
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
index c1e6d01..1ba630d 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java
@@ -75,8 +75,8 @@ public class Mobibot extends PircBot {
// The info strings.
private static final String[] INFO_STRS = {
- ReleaseInfo.PROJECT + " v" + ReleaseInfo.VERSION + " by Erik C. Thauvin (erik@thauvin.net)",
- "https://www.mobitopia.org/mobibot/"
+ ReleaseInfo.PROJECT + " v" + ReleaseInfo.VERSION + " by Erik C. Thauvin (erik@thauvin.net)",
+ "https://www.mobitopia.org/mobibot/"
};
// The link match string.
@@ -105,34 +105,31 @@ public class Mobibot extends PircBot {
// The version strings.
private static final String[] VERSION_STRS = {
- "Version: "
- + ReleaseInfo.VERSION
- + " ("
- + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
- "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")
- + ')'
+ "Version: "
+ + ReleaseInfo.VERSION
+ + " ("
+ + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
+ "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")
+ + ')'
};
-
- // The tell object.
- private static Tell tell;
// The commands list.
private final List commandsList = new ArrayList<>();
// The entries array.
@@ -145,43 +142,32 @@ public class Mobibot extends PircBot {
private final String ircChannel;
// The IRC port.
private final int ircPort;
-
// The IRC server.
private final String ircServer;
-
// The logger.
private final Logger logger = LogManager.getLogger(Mobibot.class);
-
// The logger default level.
private final Level loggerLevel;
-
// The log directory.
private final String logsDir;
-
// The recap array.
private final List recap = new ArrayList<>(0);
-
// The backlogs URL.
private String backLogsUrl = "";
-
// The default tags/categories.
private String defaultTags = "";
-
// The feed URL.
private String feedURL = "";
-
// The ident message.
private String identMsg = "";
-
// The ident nick.
private String identNick = "";
-
// The NickServ ident password.
private String identPwd = "";
-
// The pinboard posts handler.
private Pinboard pinboard = null;
-
+ // The tell object.
+ private Tell tell;
// Today's date.
private String today = Utils.today();
@@ -245,7 +231,7 @@ public class Mobibot extends PircBot {
setVersion(p.getProperty("weblog", ""));
setMessageDelay(MESSAGE_DELAY);
setIdentity(p.getProperty("ident", ""), p.getProperty("ident-nick", ""),
- p.getProperty("ident-msg", ""));
+ p.getProperty("ident-msg", ""));
// Set the URLs
setWeblogUrl(getVersion());
@@ -271,11 +257,11 @@ public class Mobibot extends PircBot {
// Load the modules properties
MODULES.stream().filter(AbstractModule::hasProperties).forEach(
- module -> {
- for (final String s : module.getPropertyKeys()) {
- module.setProperty(s, p.getProperty(s, ""));
- }
- });
+ module -> {
+ for (final String s : module.getPropertyKeys()) {
+ module.setProperty(s, p.getProperty(s, ""));
+ }
+ });
// Get the tell command settings
tell = new Tell(this, p.getProperty("tell-max-days"), p.getProperty("tell-max-size"));
@@ -330,7 +316,7 @@ public class Mobibot extends PircBot {
final Properties p = new Properties();
try (final FileInputStream fis = new FileInputStream(
- new File(line.getOptionValue(Commands.PROPS_ARG.charAt(0), "./mobibot.properties")))) {
+ line.getOptionValue(Commands.PROPS_ARG.charAt(0), "./mobibot.properties"))) {
// Load the properties files
p.load(fis);
} catch (FileNotFoundException e) {
@@ -353,7 +339,7 @@ public class Mobibot extends PircBot {
try {
stdout = new PrintStream(new FileOutputStream(
- logsDir + channel.substring(1) + '.' + Utils.today() + ".log", true));
+ logsDir + channel.substring(1) + '.' + Utils.today() + ".log", true));
} catch (IOException e) {
System.err.println("Unable to open output (stdout) log file.");
e.printStackTrace(System.err);
@@ -364,7 +350,7 @@ public class Mobibot extends PircBot {
try {
stderr = new PrintStream(
- new FileOutputStream(logsDir + nickname + ".err", true));
+ new FileOutputStream(logsDir + nickname + ".err", true));
} catch (IOException e) {
System.err.println("Unable to open error (stderr) log file.");
e.printStackTrace(System.err);
@@ -436,8 +422,8 @@ public class Mobibot extends PircBot {
if (retries == MAX_RECONNECT) {
if (logger.isDebugEnabled()) {
logger.debug(
- "Unable to reconnect to " + ircServer + " after " + MAX_RECONNECT + " retries.",
- ex);
+ "Unable to reconnect to " + ircServer + " after " + MAX_RECONNECT + " retries.",
+ ex);
}
e.printStackTrace(System.err);
@@ -550,9 +536,9 @@ public class Mobibot extends PircBot {
for (final char c : getNick().toCharArray()) {
if (Character.isLetter(c)) {
buff.append('[')
- .append(String.valueOf(c).toLowerCase())
- .append(String.valueOf(c).toUpperCase())
- .append(']');
+ .append(String.valueOf(c).toLowerCase())
+ .append(String.valueOf(c).toUpperCase())
+ .append(']');
} else {
buff.append(c);
}
@@ -699,7 +685,7 @@ public class Mobibot extends PircBot {
commandsList.add(Commands.VIEW_CMD);
MODULES.stream().filter(AbstractModule::isEnabled).forEach(
- module -> commandsList.addAll(module.getCommands()));
+ module -> commandsList.addAll(module.getCommands()));
if (tell.isEnabled()) {
commandsList.add(Tell.TELL_CMD);
@@ -729,11 +715,11 @@ public class Mobibot extends PircBot {
if (isOp(sender)) {
send(sender, "The op commands are:");
send(sender, helpIndent(
- Commands.CYCLE_CMD + " "
- + Commands.ME_CMD + " "
- + Commands.MSG_CMD + " "
- + Commands.SAY_CMD + " "
- + Commands.VERSION_CMD));
+ Commands.CYCLE_CMD + " "
+ + Commands.ME_CMD + " "
+ + Commands.MSG_CMD + " "
+ + Commands.SAY_CMD + " "
+ + Commands.VERSION_CMD));
}
}
}
@@ -1524,7 +1510,7 @@ public class Mobibot extends PircBot {
*/
private void storeRecap(final String sender, final String message, final boolean isAction) {
recap.add(Utils.utcDateTime(LocalDateTime.now(Clock.systemUTC())) + " -> " + sender + (isAction ? " " : ": ")
- + message);
+ + message);
if (recap.size() > MAX_RECAP) {
recap.remove(0);
@@ -1624,13 +1610,13 @@ public class Mobibot extends PircBot {
if (lcArgs.length() > 0) {
if ((entry.getLink().toLowerCase().contains(lcArgs)) ||
- (entry.getTitle().toLowerCase().contains(lcArgs)) ||
- (entry.getNick().toLowerCase().contains(lcArgs))) {
+ (entry.getTitle().toLowerCase().contains(lcArgs)) ||
+ (entry.getNick().toLowerCase().contains(lcArgs))) {
if (sent > MAX_ENTRIES) {
send(sender,
- "To view more, try: " + Utils
- .bold(getNick() + ": " + Commands.VIEW_CMD + ' ' + (i + 1) + ' ' + lcArgs),
- isPrivate);
+ "To view more, try: " + Utils
+ .bold(getNick() + ": " + Commands.VIEW_CMD + ' ' + (i + 1) + ' ' + lcArgs),
+ isPrivate);
break;
}
@@ -1641,9 +1627,9 @@ public class Mobibot extends PircBot {
} else {
if (sent > MAX_ENTRIES) {
send(sender,
- "To view more, try: " + Utils
- .bold(getNick() + ": " + Commands.VIEW_CMD + ' ' + (i + 1)),
- isPrivate);
+ "To view more, try: " + Utils
+ .bold(getNick() + ": " + Commands.VIEW_CMD + ' ' + (i + 1)),
+ isPrivate);
break;
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/Pinboard.java b/src/main/java/net/thauvin/erik/mobibot/Pinboard.java
index 85da409..222567b 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Pinboard.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Pinboard.java
@@ -82,12 +82,12 @@ class Pinboard {
final SwingWorker worker = new SwingWorker() {
@Override
protected Boolean doInBackground()
- throws Exception {
+ throws Exception {
return pinboard.addPin(entry.getLink(),
- entry.getTitle(),
- postedBy(entry),
- entry.getPinboardTags(),
- formatDate(entry.getDate()));
+ entry.getTitle(),
+ postedBy(entry),
+ entry.getPinboardTags(),
+ formatDate(entry.getDate()));
}
};
@@ -105,7 +105,7 @@ class Pinboard {
final SwingWorker worker = new SwingWorker() {
@Override
protected Boolean doInBackground()
- throws Exception {
+ throws Exception {
return pinboard.deletePin(link);
}
};
@@ -143,23 +143,23 @@ class Pinboard {
final SwingWorker worker = new SwingWorker() {
@Override
protected Boolean doInBackground()
- throws Exception {
+ throws Exception {
if (!oldUrl.equals(entry.getLink())) {
pinboard.deletePin(oldUrl);
return pinboard.addPin(entry.getLink(),
- entry.getTitle(),
- postedBy(entry),
- entry.getPinboardTags(),
- formatDate(entry.getDate()));
+ entry.getTitle(),
+ postedBy(entry),
+ entry.getPinboardTags(),
+ formatDate(entry.getDate()));
} else {
return pinboard.addPin(entry.getLink(),
- entry.getTitle(),
- postedBy(entry),
- entry.getPinboardTags(),
- formatDate(entry.getDate()),
- true,
- true);
+ entry.getTitle(),
+ postedBy(entry),
+ entry.getPinboardTags(),
+ formatDate(entry.getDate()),
+ true,
+ true);
}
}
};
diff --git a/src/main/java/net/thauvin/erik/mobibot/Tell.java b/src/main/java/net/thauvin/erik/mobibot/Tell.java
index c32f4f5..89f6a4e 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Tell.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Tell.java
@@ -146,9 +146,9 @@ public class Tell {
if (messages.size() > 0) {
for (final TellMessage message : messages) {
bot.send(sender, Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient())
- + " [ID: " + message.getId() + ", "
- + (message.isReceived() ? "DELIVERED" : "QUEUED") + ']',
- true);
+ + " [ID: " + message.getId() + ", "
+ + (message.isReceived() ? "DELIVERED" : "QUEUED") + ']',
+ true);
}
} else {
bot.send(sender, "There are no messages in the queue.", true);
@@ -165,17 +165,17 @@ public class Tell {
if (message.isReceived()) {
bot.send(sender,
- Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient())
- + " [" + Utils.utcDateTime(message.getReceived()) + ", ID: "
- + message.getId() + ", DELIVERED]",
- true);
+ Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient())
+ + " [" + Utils.utcDateTime(message.getReceived()) + ", ID: "
+ + message.getId() + ", DELIVERED]",
+ true);
} else {
bot.send(sender,
- Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient())
- + " [" + Utils.utcDateTime(message.getQueued()) + ", ID: "
- + message.getId() + ", QUEUED]",
- true);
+ Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient())
+ + " [" + Utils.utcDateTime(message.getQueued()) + ", ID: "
+ + message.getId() + ", QUEUED]",
+ true);
}
bot.send(sender, bot.helpIndent(message.getMessage(), false), true);
@@ -187,10 +187,10 @@ public class Tell {
} else {
bot.send(sender, "To delete one or all delivered messages:");
bot.send(sender,
- bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + TELL_DEL_KEYWORD + " '));
+ bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + TELL_DEL_KEYWORD + " '));
bot.send(sender, "Messages are kept for " + Utils.bold(maxDays)
- + Utils.plural(maxDays, " day.", " days."));
+ + Utils.plural(maxDays, " day.", " days."));
}
}
} else if (cmds.startsWith(TELL_DEL_KEYWORD + ' ')) {
@@ -254,7 +254,7 @@ public class Tell {
save();
bot.send(sender, "Message [ID " + message.getId() + "] was queued for "
- + Utils.bold(message.getRecipient()), true);
+ + Utils.bold(message.getRecipient()), true);
} else {
bot.send(sender, "Sorry, the messages queue is currently full.", true);
}
@@ -282,42 +282,42 @@ public class Tell {
public void send(final String nickname, final boolean isMessage) {
if (!nickname.equals(bot.getNick()) && isEnabled()) {
messages.stream().filter(message -> message.isMatch(nickname)).forEach(
- message -> {
- if (message.getRecipient().equalsIgnoreCase(nickname) && !message.isReceived()) {
- if (message.getSender().equals(nickname)) {
- if (!isMessage) {
- bot.send(nickname, Utils.bold("You") + " wanted me to remind you: "
- + Utils.reverseColor(message.getMessage()),
- true);
-
- message.setIsReceived();
- message.setIsNotified();
-
- save();
- }
- } else {
- bot.send(nickname, message.getSender() + " wanted me to tell you: "
- + Utils.reverseColor(message.getMessage()),
- true);
+ message -> {
+ if (message.getRecipient().equalsIgnoreCase(nickname) && !message.isReceived()) {
+ if (message.getSender().equals(nickname)) {
+ if (!isMessage) {
+ bot.send(nickname, Utils.bold("You") + " wanted me to remind you: "
+ + Utils.reverseColor(message.getMessage()),
+ true);
message.setIsReceived();
+ message.setIsNotified();
save();
}
- } else if (message.getSender().equalsIgnoreCase(nickname) && message.isReceived()
- && !message.isNotified()) {
- bot.send(nickname,
- "Your message "
- + Utils.reverseColor("[ID " + message.getId() + ']') + " was sent to "
- + Utils.bold(message.getRecipient()) + " on "
- + Utils.utcDateTime(message.getReceived()),
- true);
+ } else {
+ bot.send(nickname, message.getSender() + " wanted me to tell you: "
+ + Utils.reverseColor(message.getMessage()),
+ true);
- message.setIsNotified();
+ message.setIsReceived();
save();
}
- });
+ } else if (message.getSender().equalsIgnoreCase(nickname) && message.isReceived()
+ && !message.isNotified()) {
+ bot.send(nickname,
+ "Your message "
+ + Utils.reverseColor("[ID " + message.getId() + ']') + " was sent to "
+ + Utils.bold(message.getRecipient()) + " on "
+ + Utils.utcDateTime(message.getReceived()),
+ true);
+
+ message.setIsNotified();
+
+ save();
+ }
+ });
}
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java b/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java
index 367e8d7..1397986 100644
--- a/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java
+++ b/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java
@@ -53,7 +53,7 @@ final class TellMessagesMgr {
* @throws UnsupportedOperationException If the constructor is called.
*/
private TellMessagesMgr()
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
@@ -129,4 +129,4 @@ final class TellMessagesMgr {
logger.error("Unable to save messages queue.", e);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java b/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
index 7796453..6745d30 100644
--- a/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
+++ b/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
@@ -43,17 +43,17 @@ public final class TwitterOAuth {
System.out.print("Enter the PIN (if available) or just hit enter.[PIN]:");
final String pin = br.readLine();
try {
- if (pin.length() > 0) {
+ if (pin != null && pin.length() > 0) {
accessToken = twitter.getOAuthAccessToken(requestToken, pin);
} else {
accessToken = twitter.getOAuthAccessToken();
}
System.out.println(
- "Please add the following to the bot's property file:" + "\n\n" + "twitter-consumerKey="
- + args[0] + '\n' + "twitter-consumerSecret=" + args[1] + '\n' + "twitter-token="
- + accessToken.getToken() + '\n' + "twitter-tokenSecret=" + accessToken
- .getTokenSecret());
+ "Please add the following to the bot's property file:" + "\n\n" + "twitter-consumerKey="
+ + args[0] + '\n' + "twitter-consumerSecret=" + args[1] + '\n' + "twitter-token="
+ + accessToken.getToken() + '\n' + "twitter-tokenSecret=" + accessToken
+ .getTokenSecret());
} catch (TwitterException te) {
if (401 == te.getStatusCode()) {
System.out.println("Unable to get the access token.");
@@ -68,4 +68,4 @@ public final class TwitterOAuth {
System.exit(0);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/mobibot/Utils.java b/src/main/java/net/thauvin/erik/mobibot/Utils.java
index 72e9a0d..ef9d181 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Utils.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Utils.java
@@ -53,7 +53,7 @@ final public class Utils {
* @throws UnsupportedOperationException If the constructor is called.
*/
private Utils()
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
@@ -87,7 +87,7 @@ final public class Utils {
*/
static String buildComment(final int entryIndex, final int commentIndex, final EntryComment comment) {
return (Commands.LINK_CMD + (entryIndex + 1) + '.' + (commentIndex + 1) + ": [" + comment.getNick() + "] "
- + comment.getComment());
+ + comment.getComment());
}
/**
@@ -316,4 +316,4 @@ final public class Utils {
return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java
index 2cb3a5e..57a33cf 100644
--- a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java
+++ b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java
@@ -137,8 +137,8 @@ final public class CurrencyConverter extends AbstractModule {
for (final Object rawCube : cubes) {
cube = (Element) rawCube;
EXCHANGE_RATES.put(
- cube.getAttribute("currency").getValue(),
- cube.getAttribute("rate").getValue());
+ cube.getAttribute("currency").getValue(),
+ cube.getAttribute("rate").getValue());
}
EXCHANGE_RATES.put("EUR", "1");
@@ -148,7 +148,7 @@ final public class CurrencyConverter extends AbstractModule {
} catch (IOException e) {
bot.getLogger().debug("Unable to fetch the exchange rates table.", e);
bot.send(sender,
- "An error has occurred while fetching the exchange rates table: " + e.getMessage());
+ "An error has occurred while fetching the exchange rates table: " + e.getMessage());
}
}
@@ -170,18 +170,18 @@ final public class CurrencyConverter extends AbstractModule {
final double to = Double.parseDouble(EXCHANGE_RATES.get(cmds[3].toUpperCase()));
bot.send(bot.getChannel(),
- NumberFormat.getCurrencyInstance(Locale.US).format(amt).substring(1)
- + ' '
- + cmds[1].toUpperCase()
- + " = "
- + NumberFormat.getCurrencyInstance(Locale.US)
- .format((amt * to) / from)
- .substring(1)
- + ' '
- + cmds[3].toUpperCase());
+ NumberFormat.getCurrencyInstance(Locale.US).format(amt).substring(1)
+ + ' '
+ + cmds[1].toUpperCase()
+ + " = "
+ + NumberFormat.getCurrencyInstance(Locale.US)
+ .format((amt * to) / from)
+ .substring(1)
+ + ' '
+ + cmds[3].toUpperCase());
} catch (NullPointerException ignored) {
bot.send(sender,
- "The supported currencies are: " + EXCHANGE_RATES.keySet().toString());
+ "The supported currencies are: " + EXCHANGE_RATES.keySet().toString());
}
}
}
@@ -206,4 +206,4 @@ final public class CurrencyConverter extends AbstractModule {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java b/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java
index d4e4253..89c9582 100644
--- a/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java
+++ b/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java
@@ -71,7 +71,7 @@ final public class Lookup extends AbstractModule {
* @throws java.net.UnknownHostException If the host is unknown.
*/
public static String lookup(final String query)
- throws UnknownHostException {
+ throws UnknownHostException {
final StringBuilder buffer = new StringBuilder("");
final InetAddress[] results = InetAddress.getAllByName(query);
@@ -106,7 +106,7 @@ final public class Lookup extends AbstractModule {
* @throws java.io.IOException If a connection error occurs.
*/
private static String[] whois(final String query)
- throws IOException {
+ throws IOException {
return whois(query, WHOIS_HOST);
}
@@ -118,9 +118,9 @@ final public class Lookup extends AbstractModule {
* @return The IP whois data, if any.
* @throws java.io.IOException If a connection error occurs.
*/
- @SuppressWarnings("WeakerAccess, SameParameterValue")
+ @SuppressWarnings("SameParameterValue")
public static String[] whois(final String query, final String host)
- throws IOException {
+ throws IOException {
final WhoisClient whois = new WhoisClient();
final String[] lines;
@@ -157,8 +157,8 @@ final public class Lookup extends AbstractModule {
bot.send(bot.getChannel(), Lookup.lookup(args));
} catch (UnknownHostException ignore) {
if (args.matches(
- "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
- "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")) {
+ "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." +
+ "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")) {
try {
final String[] lines = Lookup.whois(args);
diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java b/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java
index 2c50499..b63a88c 100644
--- a/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java
+++ b/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java
@@ -106,21 +106,21 @@ final public class Twitter extends AbstractModule {
try {
final ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
- .setOAuthConsumerKey(properties.get(CONSUMER_KEY_PROP))
- .setOAuthConsumerSecret(properties.get(CONSUMER_SECRET_PROP))
- .setOAuthAccessToken(properties.get(TOKEN_PROP))
- .setOAuthAccessTokenSecret(properties.get(TOKEN_SECRET_PROP));
+ .setOAuthConsumerKey(properties.get(CONSUMER_KEY_PROP))
+ .setOAuthConsumerSecret(properties.get(CONSUMER_SECRET_PROP))
+ .setOAuthAccessToken(properties.get(TOKEN_PROP))
+ .setOAuthAccessTokenSecret(properties.get(TOKEN_SECRET_PROP));
final TwitterFactory tf = new TwitterFactory(cb.build());
final twitter4j.Twitter twitter = tf.getInstance();
final Status status = twitter.updateStatus(message + " (" + sender + ')');
bot.send(sender,
- "You message was posted to http://twitter.com/" + twitter.getScreenName() + "/statuses/" + status
- .getId());
+ "You message was posted to http://twitter.com/" + twitter.getScreenName() + "/statuses/" + status
+ .getId());
} catch (Exception e) {
bot.getLogger().warn("Unable to post to Twitter: " + message, e);
bot.send(sender, "An error has occurred: " + e.getMessage());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java b/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java
index 8bba863..02e680e 100644
--- a/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java
+++ b/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java
@@ -143,8 +143,8 @@ final public class WorldTime extends AbstractModule {
COUNTRIES_MAP.put("BEATS", BEATS_KEYWORD);
ZoneId.getAvailableZoneIds().stream().filter(
- tz -> !tz.contains("/") && tz.length() == 3 && !COUNTRIES_MAP.containsKey(tz)).forEach(
- tz -> COUNTRIES_MAP.put(tz, tz));
+ tz -> !tz.contains("/") && tz.length() == 3 && !COUNTRIES_MAP.containsKey(tz)).forEach(
+ tz -> COUNTRIES_MAP.put(tz, tz));
}
/**
@@ -166,8 +166,8 @@ final public class WorldTime extends AbstractModule {
response = ("The current Internet Time is: " + internetTime() + ' ' + BEATS_KEYWORD);
} else {
response = ZonedDateTime.now().withZoneSameInstant(ZoneId.of(tz)).format(
- DateTimeFormatter.ofPattern("'The time is 'HH:mm' on 'EEEE, d MMMM yyyy' in '"))
- + tz.substring(tz.indexOf('/') + 1).replace('_', ' ');
+ DateTimeFormatter.ofPattern("'The time is 'HH:mm' on 'EEEE, d MMMM yyyy' in '"))
+ + tz.substring(tz.indexOf('/') + 1).replace('_', ' ');
}
} else {
isInvalidTz = true;
@@ -205,7 +205,7 @@ final public class WorldTime extends AbstractModule {
private String internetTime() {
final ZonedDateTime zdt = ZonedDateTime.now(ZoneId.of("UTC+01:00"));
final int beats = (int) ((zdt.get(ChronoField.SECOND_OF_MINUTE) + (zdt.get(ChronoField.MINUTE_OF_HOUR) * 60)
- + (zdt.get(ChronoField.HOUR_OF_DAY) * 3600)) / 86.4);
+ + (zdt.get(ChronoField.HOUR_OF_DAY) * 3600)) / 86.4);
return String.format("%c%03d", '@', beats);
}
@@ -216,4 +216,4 @@ final public class WorldTime extends AbstractModule {
public boolean isPrivateMsgEnabled() {
return true;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/net/thauvin/erik/mobibot/UtilsTest.java b/src/test/java/net/thauvin/erik/mobibot/UtilsTest.java
index 8e18cd2..a710d3e 100644
--- a/src/test/java/net/thauvin/erik/mobibot/UtilsTest.java
+++ b/src/test/java/net/thauvin/erik/mobibot/UtilsTest.java
@@ -50,11 +50,11 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class UtilsTest {
static final String ASCII =
- " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
+ " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
final Calendar cal = Calendar.getInstance();
final LocalDateTime localDateTime =
- LocalDateTime.of(1952, 2, 17, 12, 30, 0);
+ LocalDateTime.of(1952, 2, 17, 12, 30, 0);
@BeforeClass
public void setUp() {
@@ -76,9 +76,9 @@ public class UtilsTest {
@Test
public void testEnsureDir() throws Exception {
assertThat(Utils.ensureDir("dir", false)).as("ensureDir(dir, false)")
- .isEqualTo("dir" + File.separatorChar);
+ .isEqualTo("dir" + File.separatorChar);
assertThat(Utils.ensureDir("https://erik.thauvin.net", true))
- .as("ensureDir(erik.thauvin.net, true)").isEqualTo("https://erik.thauvin.net/");
+ .as("ensureDir(erik.thauvin.net, true)").isEqualTo("https://erik.thauvin.net/");
}
@Test
@@ -131,13 +131,13 @@ public class UtilsTest {
@Test
public void testUnescapeXml() throws Exception {
assertThat(Utils.unescapeXml("<a name="test & ''">"))
- .isEqualTo("");
+ .isEqualTo("");
}
@Test
public void testUtcDateTime() throws Exception {
assertThat(Utils.utcDateTime(cal.getTime())).as("utcDateTime(date)").isEqualTo("1952-02-17 12:30");
assertThat(Utils.utcDateTime(localDateTime)).as("utcDateTime(localDate)")
- .isEqualTo("1952-02-17 12:30");
+ .isEqualTo("1952-02-17 12:30");
}
-}
\ No newline at end of file
+}
diff --git a/version.properties b/version.properties
index 434dfb8..8fe2cde 100644
--- a/version.properties
+++ b/version.properties
@@ -1,8 +1,7 @@
-#Sun, 29 Oct 2017 09:38:57 -0700
-#Mon Dec 07 01:31:00 PST 2015
-version.project=mobibot
+#Generated by the Semver Plugin for Gradle
+#Fri Jul 13 00:45:23 PDT 2018
+version.prerelease=beta
+version.buildmeta=1
+version.patch=3
version.major=0
version.minor=7
-version.patch=2
-version.prerelease=beta
-version.buildmeta=030