Cleanup, copyright, etc.
This commit is contained in:
parent
fd6c1309e3
commit
c078a51ebf
26 changed files with 167 additions and 126 deletions
2
.idea/mobibot.iml
generated
2
.idea/mobibot.iml
generated
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="mobibot" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="0.7.3-beta+660" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.id="mobibot" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="0.7.3-beta+682" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_14" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
|
|
2
.idea/modules/mobibot.main.iml
generated
2
.idea/modules/mobibot.main.iml
generated
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="mobibot:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="0.7.3-beta+660" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.id="mobibot:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="0.7.3-beta+682" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="3" platform="JVM 1.6" allPlatforms="JVM [1.6]" useProjectSettings="false">
|
||||
|
|
2
.idea/modules/mobibot.test.iml
generated
2
.idea/modules/mobibot.test.iml
generated
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="mobibot:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="0.7.3-beta+660" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.id="mobibot:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="0.7.3-beta+682" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="3" platform="JVM 1.6" allPlatforms="JVM [1.6]" useProjectSettings="false">
|
||||
|
|
|
@ -14,13 +14,13 @@ import java.time.*;
|
|||
public final class ReleaseInfo {
|
||||
public static final String PROJECT = "mobibot";
|
||||
public static final LocalDateTime BUILDDATE =
|
||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(1584966079848L), ZoneId.systemDefault());
|
||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(1584991174842L), ZoneId.systemDefault());
|
||||
public static final int MAJOR = 0;
|
||||
public static final int MINOR = 7;
|
||||
public static final int PATCH = 3;
|
||||
public static final String PRERELEASE = "beta";
|
||||
public static final String BUILDMETA = "682";
|
||||
public static final String VERSION = "0.7.3-beta+682";
|
||||
public static final String BUILDMETA = "704";
|
||||
public static final String VERSION = "0.7.3-beta+704";
|
||||
|
||||
/**
|
||||
* Disables the default constructor.
|
||||
|
|
|
@ -49,19 +49,19 @@ import java.util.List;
|
|||
* @since 1.0
|
||||
*/
|
||||
class FeedReader implements Runnable {
|
||||
// The maximum number of feed items to display.
|
||||
// Maximum number of feed items to display
|
||||
private static final int MAX_ITEMS = 5;
|
||||
|
||||
// The tab indent (4 spaces).
|
||||
// Tab indent (4 spaces)
|
||||
private static final String TAB_INDENT = " ";
|
||||
|
||||
// The bot.
|
||||
// Bot
|
||||
private final Mobibot bot;
|
||||
|
||||
// The nick of the person who sent the message.
|
||||
// Nick of the person who sent the message
|
||||
private final String sender;
|
||||
|
||||
// The URL to fetch.
|
||||
// URL to fetch
|
||||
private final String url;
|
||||
|
||||
/**
|
||||
|
|
|
@ -108,40 +108,40 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
className = "ReleaseInfo")
|
||||
public class Mobibot extends PircBot {
|
||||
|
||||
// The default port.
|
||||
// Default port
|
||||
private static final int DEFAULT_PORT = 6667;
|
||||
|
||||
// The default server.
|
||||
// Default server
|
||||
private static final String DEFAULT_SERVER = "irc.freenode.net";
|
||||
|
||||
// The info strings.
|
||||
// Info strings
|
||||
@SuppressWarnings("indentation")
|
||||
private static final String[] INFO_STRS = {
|
||||
ReleaseInfo.PROJECT + " v" + ReleaseInfo.VERSION + " by Erik C. Thauvin (erik@thauvin.net)",
|
||||
"https://www.mobitopia.org/mobibot/" };
|
||||
|
||||
// The link match string.
|
||||
// Link match string
|
||||
private static final String LINK_MATCH = "^[hH][tT][tT][pP](|[sS])://.*";
|
||||
|
||||
// The default maximum number of entries to display.
|
||||
// Default maximum number of entries to display
|
||||
private static final int MAX_ENTRIES = 8;
|
||||
|
||||
// The default maximum recap entries.
|
||||
// Default maximum recap entries
|
||||
private static final int MAX_RECAP = 10;
|
||||
|
||||
// The maximum number of times the bot will try to reconnect, if disconnected.
|
||||
// Maximum number of times the bot will try to reconnect, if disconnected
|
||||
private static final int MAX_RECONNECT = 10;
|
||||
|
||||
// The number of milliseconds to delay between consecutive messages.
|
||||
// Number of milliseconds to delay between consecutive messages
|
||||
private static final long MESSAGE_DELAY = 1000L;
|
||||
|
||||
// The modules.
|
||||
// Modules
|
||||
private static final List<AbstractModule> MODULES = new ArrayList<>(0);
|
||||
|
||||
// The tags/categories marker.
|
||||
// Tags/categories marker
|
||||
private static final String TAGS_MARKER = "tags:";
|
||||
|
||||
/* The version strings.*/
|
||||
// Version strings
|
||||
@SuppressWarnings("indentation")
|
||||
private static final String[] VERSION_STRS =
|
||||
{ "Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')',
|
||||
|
@ -151,53 +151,53 @@ public class Mobibot extends PircBot {
|
|||
"java.runtime.version") + ')',
|
||||
"VM: " + System.getProperty("java.vm.name") + " (build " + System.getProperty("java.vm.version") + ", "
|
||||
+ System.getProperty("java.vm.info") + ')' };
|
||||
// The logger.
|
||||
// Logger
|
||||
private static final Logger logger = LogManager.getLogger(Mobibot.class);
|
||||
// The commands list.
|
||||
// Commands list
|
||||
private final List<String> commandsList = new ArrayList<>();
|
||||
// The entries array.
|
||||
// Entries array
|
||||
private final List<EntryLink> entries = new ArrayList<>(0);
|
||||
// The history/backlogs array.
|
||||
// History/backlogs array
|
||||
private final List<String> history = new ArrayList<>(0);
|
||||
// The ignored nicks array.
|
||||
// Ignored nicks array
|
||||
private final Set<String> ignoredNicks = new HashSet<>(0);
|
||||
// The main channel.
|
||||
// Main channel
|
||||
private final String ircChannel;
|
||||
// The IRC port.
|
||||
// IRC port
|
||||
private final int ircPort;
|
||||
// The IRC server.
|
||||
// IRC server
|
||||
private final String ircServer;
|
||||
// The logger default level.
|
||||
// Logger default level
|
||||
private final Level loggerLevel;
|
||||
// The log directory.
|
||||
// Log directory
|
||||
private final String logsDir;
|
||||
// The recap array.
|
||||
// Recap array
|
||||
private final List<String> recap = new ArrayList<>(0);
|
||||
// The tell object.
|
||||
// Tell object
|
||||
private final Tell tell;
|
||||
// The Twitter handle for channel join notifications.
|
||||
// Automatically post links to Twitter
|
||||
private final boolean twitterAutoPost;
|
||||
// Twitter handle for channel join notifications
|
||||
private final String twitterHandle;
|
||||
// The Twitter module.
|
||||
// Twitter module
|
||||
private final Twitter twitterModule;
|
||||
// The backlogs URL.
|
||||
// Backlogs URL
|
||||
private String backLogsUrl = "";
|
||||
// The default tags/categories.
|
||||
// Default tags/categories
|
||||
private String defaultTags = "";
|
||||
// The feed URL.
|
||||
// Feed URL
|
||||
private String feedUrl = "";
|
||||
// The ident message.
|
||||
// Ident message
|
||||
private String identMsg = "";
|
||||
// The ident nick.
|
||||
// Ident nick
|
||||
private String identNick = "";
|
||||
// The NickServ ident password.
|
||||
// NickServ ident password
|
||||
private String identPwd = "";
|
||||
// The pinboard posts handler.
|
||||
// Pinboard posts handler
|
||||
private Pinboard pinboard;
|
||||
// Today's date.
|
||||
// Today's date
|
||||
private String today = Utils.today();
|
||||
// The weblog URL.
|
||||
// Weblog URL
|
||||
private String weblogUrl = "";
|
||||
|
||||
/**
|
||||
|
@ -225,7 +225,7 @@ public class Mobibot extends PircBot {
|
|||
// Set the logger level
|
||||
loggerLevel = logger.getLevel();
|
||||
|
||||
// Load the current entries, if any.
|
||||
// Load the current entries, if any
|
||||
try {
|
||||
today = EntriesMgr.loadEntries(logsDir + EntriesMgr.CURRENT_XML, ircChannel, entries);
|
||||
|
||||
|
@ -238,18 +238,18 @@ public class Mobibot extends PircBot {
|
|||
today = Utils.today();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
} catch (FeedException e) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("An error occurred while parsing the '" + EntriesMgr.CURRENT_XML + "' file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Load the backlogs, if any.
|
||||
// Load the backlogs, if any
|
||||
try {
|
||||
EntriesMgr.loadBacklogs(logsDir + EntriesMgr.NAV_XML, history);
|
||||
} catch (IOException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
} catch (FeedException e) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("An error occurred while parsing the '" + EntriesMgr.NAV_XML + "' file.", e);
|
||||
|
@ -421,7 +421,7 @@ public class Mobibot extends PircBot {
|
|||
try {
|
||||
Thread.sleep(secs * 1000L);
|
||||
} catch (InterruptedException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -956,8 +956,13 @@ public class Mobibot extends PircBot {
|
|||
final String htmlTitle = html.title();
|
||||
|
||||
if (isNotBlank(htmlTitle)) {
|
||||
final String[] split = htmlTitle.split("( \\| )", 2);
|
||||
if (split.length == 2) {
|
||||
title = split[0];
|
||||
} else {
|
||||
title = htmlTitle;
|
||||
}
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
// Do nothing
|
||||
}
|
||||
|
@ -969,6 +974,7 @@ public class Mobibot extends PircBot {
|
|||
final EntryLink entry = entries.get(index);
|
||||
send(channel, EntriesUtils.buildLink(index, entry));
|
||||
|
||||
// Add link to pinboard
|
||||
if (pinboard != null) {
|
||||
pinboard.addPost(entry);
|
||||
}
|
||||
|
@ -1038,7 +1044,7 @@ public class Mobibot extends PircBot {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (message.matches(Commands.LINK_CMD + "[0-9]+:.*")) { // L1:<comment>, L1:-, L1:|<title>, etc.
|
||||
} else if (message.matches(Commands.LINK_CMD + "[0-9]+:.*")) { // L1:<comment>, L1:-, L1:|<title>, etc
|
||||
isCommand = true;
|
||||
|
||||
final String[] cmds = message.substring(1).split(":", 2);
|
||||
|
@ -1165,7 +1171,7 @@ public class Mobibot extends PircBot {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (message.matches(Commands.LINK_CMD + "[0-9]+\\.[0-9]+:.*")) { // L1.1:<command>
|
||||
} else if (message.matches(Commands.LINK_CMD + "[0-9]+\\.[0-9]+:.*")) { // L11:<command>
|
||||
isCommand = true;
|
||||
|
||||
final String[] cmds = message.substring(1).split("[.:]", 3);
|
||||
|
@ -1178,15 +1184,15 @@ public class Mobibot extends PircBot {
|
|||
if (cindex < entry.getCommentsCount()) {
|
||||
final String cmd = cmds[2].trim();
|
||||
|
||||
// L1.1:
|
||||
// L11:
|
||||
if (cmd.length() == 0) {
|
||||
final EntryComment comment = entry.getComment(cindex);
|
||||
send(channel, EntriesUtils.buildComment(index, cindex, comment));
|
||||
} else if ("-".equals(cmd)) { // L1.1:-
|
||||
} else if ("-".equals(cmd)) { // L11:-
|
||||
entry.deleteComment(cindex);
|
||||
send(channel, "Comment " + Commands.LINK_CMD + (index + 1) + '.' + (cindex + 1) + " removed.");
|
||||
saveEntries(false);
|
||||
} else if (cmd.charAt(0) == '?') { // L1.1:?<author>
|
||||
} else if (cmd.charAt(0) == '?') { // L11:?<author>
|
||||
if (isOp(sender)) {
|
||||
if (cmd.length() > 1) {
|
||||
final EntryComment comment = entry.getComment(cindex);
|
||||
|
@ -1258,7 +1264,7 @@ public class Mobibot extends PircBot {
|
|||
} else if (Commands.USERS_CMD.equals(cmd)) {
|
||||
usersResponse(sender, true);
|
||||
} else if ((cmds.length > 1) && isOp(sender) && Commands.ADDLOG_CMD.equals(cmd)) {
|
||||
// e.g. 2014-04-01
|
||||
// e.g 2014-04-01
|
||||
final File backlog = new File(logsDir + args + EntriesMgr.XML_EXT);
|
||||
if (backlog.exists()) {
|
||||
history.add(0, args);
|
||||
|
@ -1557,7 +1563,10 @@ public class Mobibot extends PircBot {
|
|||
if (twitterModule.isEnabled() && isNotBlank(twitterHandle)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
twitterModule.post(twitterHandle, getName() + ' ' + ReleaseInfo.VERSION + " " + msg, true);
|
||||
twitterModule.post(
|
||||
twitterHandle,
|
||||
getName() + ' ' + ReleaseInfo.VERSION + " " + msg,
|
||||
true);
|
||||
} catch (ModuleException e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to notify @{}: {}", twitterHandle, msg, e);
|
||||
|
@ -1647,7 +1656,7 @@ public class Mobibot extends PircBot {
|
|||
i = 0;
|
||||
}
|
||||
} catch (NumberFormatException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* EntriesMgr.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -81,7 +81,7 @@ public final class EntriesMgr {
|
|||
*/
|
||||
public static final String XML_EXT = ".xml";
|
||||
|
||||
// The maximum number of backlogs to keep.
|
||||
// Maximum number of backlogs to keep
|
||||
private static final int MAX_BACKLOGS = 10;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* EntryComment.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,10 +44,10 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
@SuppressWarnings({"PMD.DataClass"})
|
||||
public class EntryComment implements Serializable {
|
||||
// The serial version UID.
|
||||
// Serial version UID
|
||||
static final long serialVersionUID = 1L;
|
||||
|
||||
// The creation date.
|
||||
// Creation date
|
||||
private final LocalDateTime date = LocalDateTime.now();
|
||||
|
||||
private String comment = "";
|
||||
|
@ -69,7 +69,7 @@ public class EntryComment implements Serializable {
|
|||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
protected EntryComment() {
|
||||
// Required for serialization.
|
||||
// Required for serialization
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* EntryLink.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -51,31 +51,31 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
* @since 1.0
|
||||
*/
|
||||
public class EntryLink implements Serializable {
|
||||
// The serial version UID.
|
||||
// Serial version UID
|
||||
static final long serialVersionUID = 1L;
|
||||
|
||||
// The link's comments
|
||||
// Link's comments
|
||||
private final List<EntryComment> comments = new CopyOnWriteArrayList<>();
|
||||
|
||||
// The tags/categories
|
||||
// Tags/categories
|
||||
private final List<SyndCategory> tags = new CopyOnWriteArrayList<>();
|
||||
|
||||
// The channel
|
||||
// Channel
|
||||
private String channel;
|
||||
|
||||
// The creation date
|
||||
// Creation date
|
||||
private Date date = Calendar.getInstance().getTime();
|
||||
|
||||
// The link's URL
|
||||
// Link's URL
|
||||
private String link;
|
||||
|
||||
// The author's login
|
||||
// Author's login
|
||||
private String login = "";
|
||||
|
||||
// The author's nickname
|
||||
// Author's nickname
|
||||
private String nick;
|
||||
|
||||
// The link's title
|
||||
// Link's title
|
||||
private String title;
|
||||
|
||||
/**
|
||||
|
@ -313,7 +313,7 @@ public class EntryLink implements Serializable {
|
|||
mod = part.charAt(0);
|
||||
|
||||
if (mod == '-') {
|
||||
// Don't remove the channel tag, if any.
|
||||
// Don't remove the channel tag, if any
|
||||
if (!channel.substring(1).equals(tag.getName())) {
|
||||
this.tags.remove(tag);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.text.DecimalFormat;
|
|||
* @since 1.0
|
||||
*/
|
||||
public class Calc extends AbstractModule {
|
||||
// The Calc command.
|
||||
// Calc command
|
||||
private static final String CALC_CMD = "calc";
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,13 +70,13 @@ public final class CurrencyConverter extends ThreadedModule {
|
|||
*/
|
||||
static final String CURRENCY_RATES_KEYWORD = "rates";
|
||||
|
||||
// The currency command.
|
||||
// Currency command
|
||||
private static final String CURRENCY_CMD = "currency";
|
||||
// The exchange rates.
|
||||
// Exchange rates
|
||||
private static final Map<String, String> EXCHANGE_RATES = new TreeMap<>();
|
||||
// The exchange rates table URL.
|
||||
// Exchange rates table URL
|
||||
private static final String EXCHANGE_TABLE_URL = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
|
||||
// The last exchange rates table publication date.
|
||||
// Last exchange rates table publication date
|
||||
private static String pubDate = "";
|
||||
|
||||
/**
|
||||
|
@ -100,7 +100,7 @@ public final class CurrencyConverter extends ThreadedModule {
|
|||
if (EXCHANGE_RATES.isEmpty()) {
|
||||
try {
|
||||
final SAXBuilder builder = new SAXBuilder();
|
||||
// See https://rules.sonarsource.com/java/tag/owasp/RSPEC-2755
|
||||
// See https://rules.sonarsourcecom/java/tag/owasp/RSPEC-2755
|
||||
builder.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
||||
builder.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
|
||||
builder.setIgnoringElementContentWhitespace(true);
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.security.SecureRandom;
|
|||
* @since 1.0
|
||||
*/
|
||||
public final class Dice extends AbstractModule {
|
||||
// The dice command.
|
||||
// Dice command
|
||||
private static final String DICE_CMD = "dice";
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,13 +60,13 @@ import java.util.List;
|
|||
* @since 1.0
|
||||
*/
|
||||
public final class GoogleSearch extends ThreadedModule {
|
||||
// The Google API Key property.
|
||||
// Google API Key property
|
||||
static final String GOOGLE_API_KEY_PROP = "google-api-key";
|
||||
// The Google Custom Search Engine ID property.
|
||||
// Google Custom Search Engine ID property
|
||||
static final String GOOGLE_CSE_KEY_PROP = "google-cse-cx";
|
||||
// The Google command
|
||||
// Google command
|
||||
private static final String GOOGLE_CMD = "google";
|
||||
// The tab indent (4 spaces).
|
||||
// Tab indent (4 spaces)
|
||||
private static final String TAB_INDENT = " ";
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,9 +52,9 @@ import java.nio.charset.StandardCharsets;
|
|||
* @since 1.0
|
||||
*/
|
||||
public final class Joke extends ThreadedModule {
|
||||
// The joke command.
|
||||
// Joke command
|
||||
private static final String JOKE_CMD = "joke";
|
||||
// The ICNDB URL.
|
||||
// ICNDB URL
|
||||
private static final String JOKE_URL =
|
||||
"http://api.icndb.com/jokes/random?escape=javascript&exclude=[explicit]&limitTo=[nerdy]";
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public final class Lookup extends AbstractModule {
|
|||
*/
|
||||
static final String WHOIS_HOST = "whois.arin.net";
|
||||
|
||||
// The lookup command.
|
||||
// Lookup command
|
||||
private static final String LOOKUP_CMD = "lookup";
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,9 +68,9 @@ public final class StockQuote extends ThreadedModule {
|
|||
* The Invalid Symbol error string.
|
||||
*/
|
||||
static final String INVALID_SYMBOL = "Invalid symbol.";
|
||||
// The Alpha Advantage URL.
|
||||
// Alpha Advantage URL
|
||||
private static final String ALAPHAVANTAGE_URL = "https://www.alphavantage.co/query?function=";
|
||||
// The quote command.
|
||||
// Quote command
|
||||
private static final String STOCK_CMD = "stock";
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ public final class StockQuote extends ThreadedModule {
|
|||
throw new ModuleException(debugMessage, Utils.unescapeXml(info));
|
||||
}
|
||||
} catch (JSONException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -104,7 +104,7 @@ public final class StockQuote extends ThreadedModule {
|
|||
throw new ModuleException(debugMessage, Utils.unescapeXml(error));
|
||||
}
|
||||
} catch (JSONException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -113,7 +113,7 @@ public final class StockQuote extends ThreadedModule {
|
|||
throw new ModuleException(debugMessage, Utils.unescapeXml(error));
|
||||
}
|
||||
} catch (JSONException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return json;
|
||||
|
|
|
@ -45,12 +45,12 @@ import java.security.SecureRandom;
|
|||
* @since 1.0
|
||||
*/
|
||||
public final class War extends AbstractModule {
|
||||
// The war command
|
||||
// War command
|
||||
private static final String WAR_CMD = "war";
|
||||
// The deck of card.
|
||||
// Deck of card
|
||||
private static final String[] WAR_DECK =
|
||||
new String[]{ "Ace", "King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2" };
|
||||
// The suits for the deck of card.
|
||||
// Suits for the deck of card
|
||||
private static final String[] WAR_SUITS = new String[]{ "Hearts", "Spades", "Diamonds", "Clubs" };
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,7 @@ public class Weather2 extends ThreadedModule {
|
|||
*/
|
||||
static final String OWM_API_KEY_PROP = "owm-api-key";
|
||||
|
||||
// The weather command.
|
||||
// Weather command
|
||||
private static final String WEATHER_CMD = "weather";
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,9 +56,9 @@ import java.util.TreeMap;
|
|||
*/
|
||||
@SuppressWarnings("PMD.UseConcurrentHashMap")
|
||||
public final class WorldTime extends AbstractModule {
|
||||
// The beats (Internet Time) keyword.
|
||||
// Beats (Internet Time) keyword
|
||||
private static final String BEATS_KEYWORD = ".beats";
|
||||
// The supported countries.
|
||||
// Supported countries
|
||||
private static final Map<String, String> COUNTRIES_MAP;
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Message.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -52,7 +52,7 @@ public class Message {
|
|||
* Creates a new message.
|
||||
*/
|
||||
public Message() {
|
||||
// This constructor is intentionally empty.
|
||||
// This constructor is intentionally empty
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Tell.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -54,26 +54,26 @@ public class Tell {
|
|||
*/
|
||||
public static final String TELL_CMD = "tell";
|
||||
|
||||
// The default maximum number of days to keep messages.
|
||||
// Default maximum number of days to keep messages
|
||||
private static final int DEFAULT_TELL_MAX_DAYS = 7;
|
||||
// The default message max queue size.
|
||||
// Default message max queue size
|
||||
private static final int DEFAULT_TELL_MAX_SIZE = 50;
|
||||
// The serialized object file extension.
|
||||
// Serialized object file extension
|
||||
private static final String SER_EXT = ".ser";
|
||||
// The all keyword.
|
||||
// All keyword
|
||||
private static final String TELL_ALL_KEYWORD = "all";
|
||||
//T he delete command.
|
||||
private static final String TELL_DEL_KEYWORD = "del";
|
||||
|
||||
// The bot instance.
|
||||
// Bot instance
|
||||
private final Mobibot bot;
|
||||
// The maximum number of days to keep messages.
|
||||
// Maximum number of days to keep messages
|
||||
private final int maxDays;
|
||||
// The message maximum queue size.
|
||||
// Message maximum queue size
|
||||
private final int maxSize;
|
||||
// The messages queue.
|
||||
// Messages queue
|
||||
private final List<TellMessage> messages = new CopyOnWriteArrayList<>();
|
||||
// The serialized object file.
|
||||
// Serialized object file
|
||||
private final String serializedObject;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ public class Tell {
|
|||
this.maxDays = Utils.getIntProperty(maxDays, DEFAULT_TELL_MAX_DAYS);
|
||||
this.maxSize = Utils.getIntProperty(maxSize, DEFAULT_TELL_MAX_SIZE);
|
||||
|
||||
// Load the message queue.
|
||||
// Load the message queue
|
||||
serializedObject = bot.getLogsDir() + bot.getName() + SER_EXT;
|
||||
messages.addAll(TellMessagesMgr.load(serializedObject, bot.getLogger()));
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* TellMessagesMgr.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -99,7 +99,7 @@ final class TellMessagesMgr {
|
|||
return ((List<TellMessage>) input.readObject());
|
||||
}
|
||||
} catch (FileNotFoundException ignore) {
|
||||
// Do nothing.
|
||||
// Do nothing
|
||||
} catch (IOException e) {
|
||||
logger.error("An IO error occurred loading the messages queue.", e);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* GoogleSearchTest.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -78,7 +78,7 @@ public class GoogleSearchTest extends LocalProperties {
|
|||
assertThatThrownBy(() -> GoogleSearch.searchGoogle("", "apikey", "apiKey")).as("no query").isInstanceOf(
|
||||
ModuleException.class).hasNoCause();
|
||||
} catch (ModuleException e) {
|
||||
// Avoid displaying api keys in CI logs.
|
||||
// Avoid displaying api keys in CI logs
|
||||
if ("true".equals(System.getenv("CI"))) {
|
||||
throw new ModuleException(e.getDebugMessage(), e.getSanitizedMessage(apiKey, cseKey));
|
||||
} else {
|
||||
|
|
|
@ -41,7 +41,7 @@ class RockPaperScissorsTest {
|
|||
@Test(invocationCount = 5)
|
||||
fun testWinLoseOrDraw() {
|
||||
var play = RockPaperScissors.winLoseOrDraw(Shapes.SCISSORS)
|
||||
// println("SCISSORS vs ${play.first}: ${play.second}")
|
||||
// println("SCISSORS vs ${play.first}: ${playsecond}")
|
||||
when (play.first) {
|
||||
Shapes.SCISSORS -> assertThat(play.second).`as`("SCISSORS vs ${play.first}").isEqualTo(Results.DRAW)
|
||||
Shapes.ROCK -> assertThat(play.second).`as`("SCISSORS vs ${play.first}").isEqualTo(Results.LOSE)
|
||||
|
@ -49,7 +49,7 @@ class RockPaperScissorsTest {
|
|||
}
|
||||
|
||||
play = RockPaperScissors.winLoseOrDraw(Shapes.ROCK)
|
||||
// println("ROCK vs ${play.first}: ${play.second}")
|
||||
// println("ROCK vs ${play.first}: ${playsecond}")
|
||||
when (play.first) {
|
||||
Shapes.SCISSORS -> assertThat(play.second).`as`("ROCK vs ${play.first}").isEqualTo(Results.WIN)
|
||||
Shapes.ROCK -> assertThat(play.second).`as`("ROCK vs ${play.first}").isEqualTo(Results.DRAW)
|
||||
|
@ -57,7 +57,7 @@ class RockPaperScissorsTest {
|
|||
}
|
||||
|
||||
play = RockPaperScissors.winLoseOrDraw(Shapes.PAPER)
|
||||
// println("PAPER vs ${play.first}: ${play.second}")
|
||||
// println("PAPER vs ${play.first}: ${playsecond}")
|
||||
when (play.first) {
|
||||
Shapes.SCISSORS -> assertThat(play.second).`as`("PAPER vs ${play.first}").isEqualTo(Results.LOSE)
|
||||
Shapes.ROCK -> assertThat(play.second).`as`("PAPER vs ${play.first}").isEqualTo(Results.WIN)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* StockQuoteTest.java
|
||||
*
|
||||
* Copyright (c) 2004-2019, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -73,7 +73,7 @@ public class StockQuoteTest extends LocalProperties {
|
|||
ModuleException.class).hasNoCause();
|
||||
|
||||
} catch (ModuleException e) {
|
||||
// Avoid displaying api keys in CI logs.
|
||||
// Avoid displaying api keys in CI logs
|
||||
if ("true".equals(System.getenv("CI"))) {
|
||||
throw new ModuleException(e.getDebugMessage(), e.getSanitizedMessage(apiKey));
|
||||
} else {
|
||||
|
|
|
@ -1,9 +1,41 @@
|
|||
#
|
||||
# version.properties
|
||||
#
|
||||
# Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of this project nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#Generated by the Semver Plugin for Gradle
|
||||
#Mon Mar 23 05:21:18 PDT 2020
|
||||
version.buildmeta=682
|
||||
#Mon Mar 23 12:19:33 PDT 2020
|
||||
version.buildmeta=704
|
||||
version.major=0
|
||||
version.minor=7
|
||||
version.patch=3
|
||||
version.prerelease=beta
|
||||
version.project=mobibot
|
||||
version.semver=0.7.3-beta+682
|
||||
version.semver=0.7.3-beta+704
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue