Added the ability to ignore links from specified nicknames.

This commit is contained in:
Erik C. Thauvin 2004-10-30 20:37:08 +00:00
parent a36b1cdd61
commit 85be0ce22b
5 changed files with 72 additions and 37 deletions

View file

@ -405,6 +405,11 @@ public class Mobibot extends PircBot
*/
private final Vector _history = new Vector(0);
/**
* The ignored nicks array.
*/
private final Vector _ignoredNicks = new Vector(0);
/**
* The backlogs URL.
*/
@ -618,6 +623,7 @@ public class Mobibot extends PircBot
final String feedURL = p.getProperty("feed", "");
final String backlogsURL = ensureDir(p.getProperty("backlogs", weblogURL), true);
final String googleKey = p.getProperty("google", "");
final String ignoredNicks = p.getProperty("ignore", "");
// Create the bot
final Mobibot bot = new Mobibot(server, channel, logsDir);
@ -638,6 +644,9 @@ public class Mobibot extends PircBot
// Set the Google key
bot.setGoogleKey(googleKey);
// Set the ignored nicks
bot.setIgnoredNicks(ignoredNicks);
// Save the entries
bot.saveEntries(true);
@ -1024,7 +1033,7 @@ public class Mobibot extends PircBot
_logger.debug(">>> " + sender + ": " + message);
}
if (message.matches(LINK_MATCH))
if (message.matches(LINK_MATCH) && !isIgnoredNick(sender))
{
final String[] cmds = message.split(" ", 2);
final String cmd = cmds[0].trim();
@ -1528,6 +1537,24 @@ public class Mobibot extends PircBot
_googleKey = googleKey;
}
/**
* Sets the Ignored nicks.
*
* @param nicks The nicks to ignore
*/
private void setIgnoredNicks(String nicks)
{
if (isValidString(nicks))
{
final StringTokenizer st = new StringTokenizer(nicks, ",");
while (st.hasMoreTokens())
{
_ignoredNicks.add(st.nextToken().trim().toLowerCase());
}
}
}
/**
* Set today's date.
*
@ -1974,7 +2001,7 @@ public class Mobibot extends PircBot
*
* @param isDayBackup Set the true if the daily backup file should also be created.
*/
private synchronized void saveEntries(boolean isDayBackup)
private void saveEntries(boolean isDayBackup)
{
if (_logger.isDebugEnabled())
{
@ -2309,6 +2336,23 @@ public class Mobibot extends PircBot
return ISO_SDF.format(Calendar.getInstance().getTime());
}
/**
* Determines whether the specified nick should be ignored.
*
* @param nick The nick.
*
* @return <code>true</code> if the nick should be ignored, <code>false</code> otherwise.
*/
private boolean isIgnoredNick(String nick)
{
if (isValidString(nick))
{
return _ignoredNicks.contains(nick.toLowerCase());
}
return false;
}
/**
* Returns the bot's nickname regexp pattern.
*

View file

@ -1,5 +1,5 @@
/* Created by JReleaseInfo AntTask from Open Source Competence Group */
/* Creation date Mon Oct 04 07:18:37 PDT 2004 */
/* Creation date Sat Oct 30 11:43:51 PDT 2004 */
package net.thauvin.erik.mobibot;
import java.util.Date;
@ -12,21 +12,21 @@ import java.util.Date;
public class ReleaseInfo {
/** buildDate (set during build process to 1096899517937L). */
private static Date buildDate = new Date(1096899517937L);
/** buildDate (set during build process to 1099161831468L). */
private static Date buildDate = new Date(1099161831468L);
/**
* Get buildDate (set during build process to Mon Oct 04 07:18:37 PDT 2004).
* Get buildDate (set during build process to Sat Oct 30 11:43:51 PDT 2004).
* @return Date buildDate
*/
public static final Date getBuildDate() { return buildDate; }
/**
* Get buildNumber (set during build process to 3).
* Get buildNumber (set during build process to 6).
* @return int buildNumber
*/
public static final int getBuildNumber() { return 3; }
public static final int getBuildNumber() { return 6; }
/** version (set during build process to "0.2"). */