Added ability to set the port.

Added NickServ registartion.
Updated to delicious 1.9 API.
Update URL to mobitopia.org.
This commit is contained in:
Erik C. Thauvin 2005-11-08 22:58:20 +00:00
parent 7c8deae99a
commit c1129adbf5
9 changed files with 350 additions and 241 deletions

View file

@ -88,7 +88,7 @@ public class Mobibot extends PircBot
private static final String[] INFO_STRS =
{
"Mobibot v" + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber() +
" by Erik C. Thauvin (erik@thauvin.net)", "http://mobitopia.thauvin.net/mobibot/"
" by Erik C. Thauvin (erik@thauvin.net)", "http://www.mobitopia.org/mobibot/"
};
/**
@ -321,6 +321,11 @@ public class Mobibot extends PircBot
*/
private static final List RECAP_ARRAY = new ArrayList(MAX_RECAP);
/**
* The default port.
*/
private static final int DEFAULT_PORT = 6667;
// Initialize the countries.
static
{
@ -442,6 +447,12 @@ public class Mobibot extends PircBot
*/
private final Vector _ignoredNicks = new Vector(0);
/**
* The IRC port.
*/
private final int _ircPort;
/**
* The IRC server.
*/
@ -478,12 +489,13 @@ public class Mobibot extends PircBot
* @param channel The channel.
* @param logsDir The logs directory.
*/
public Mobibot(String server, String channel, String logsDir)
public Mobibot(String server, int port, String channel, String logsDir)
{
System.getProperties().setProperty("sun.net.client.defaultConnectTimeout", String.valueOf(CONNECT_TIMEOUT));
System.getProperties().setProperty("sun.net.client.defaultReadTimeout", String.valueOf(CONNECT_TIMEOUT));
_ircServer = server;
_ircPort = port;
_channel = channel;
_logsDir = logsDir;
@ -619,6 +631,7 @@ public class Mobibot extends PircBot
// Get the main properties
final String channel = p.getProperty("channel");
final String server = p.getProperty("server");
final int port = getPort(p.getProperty("port", String.valueOf(DEFAULT_PORT)), DEFAULT_PORT);
final String nickname = p.getProperty("nick", Mobibot.class.getName().toLowerCase());
final String logsDir = ensureDir(p.getProperty("logs", "."), false);
@ -664,6 +677,8 @@ public class Mobibot extends PircBot
final String backlogsURL = ensureDir(p.getProperty("backlogs", weblogURL), true);
final String googleKey = p.getProperty("google", "");
final String ignoredNicks = p.getProperty("ignore", "");
final String identNick = p.getProperty("ident-nick", "");
final String identMsg = p.getProperty("ident-msg", "");
final String tags = p.getProperty("tags", "");
// Get the del.icio.us properties
@ -671,7 +686,7 @@ public class Mobibot extends PircBot
final String dpwd = p.getProperty("delicious-pwd");
// Create the bot
final Mobibot bot = new Mobibot(server, channel, logsDir);
final Mobibot bot = new Mobibot(server, port, channel, logsDir);
// Initialize the bot
bot.setVerbose(true);
@ -708,7 +723,7 @@ public class Mobibot extends PircBot
// Connect
try
{
bot.connect(server);
bot.connect(server, port);
}
catch (Exception e)
{
@ -720,7 +735,7 @@ public class Mobibot extends PircBot
try
{
bot.connect(server);
bot.connect(server, port);
}
catch (Exception ex)
{
@ -736,10 +751,17 @@ public class Mobibot extends PircBot
}
bot.setVersion(INFO_STRS[0]);
if (isValidString(identNick) && isValidString(identMsg))
{
bot.sendMessage(identNick, identMsg);
}
bot.joinChannel(channel);
}
}
/**
* Converts XML/XHTML entities to plain text.
*
@ -1058,7 +1080,7 @@ public class Mobibot extends PircBot
// Connect
try
{
connect(_ircServer);
connect(_ircServer, _ircPort);
}
catch (Exception e)
{
@ -1070,7 +1092,7 @@ public class Mobibot extends PircBot
try
{
connect(_ircServer);
connect(_ircServer, _ircPort);
}
catch (Exception ex)
{
@ -1815,11 +1837,11 @@ public class Mobibot extends PircBot
{
final StringBuffer buff = new StringBuffer(LINK_CMD + (index + 1) + ": ");
buff.append('[' + entry.getNick() + ']');
buff.append('[').append(entry.getNick()).append(']');
if (isView && entry.hasComments())
{
buff.append("[+" + entry.getCommentsCount() + ']');
buff.append("[+").append(entry.getCommentsCount()).append(']');
}
buff.append(' ');
@ -1885,6 +1907,30 @@ public class Mobibot extends PircBot
}
}
/**
* Returns the port.
*
* @param property The port property value.
* @param defaultValue The default value.
*
* @return The port or default value if invalid.
*/
private static int getPort(String property, int defaultValue)
{
int port;
try
{
port = Integer.parseInt(property);
}
catch (NumberFormatException ignore)
{
port = defaultValue;
}
return port;
}
/**
* Returns the current Internet (beat) Time.
*

View file

@ -1,5 +1,5 @@
/* Created by JReleaseInfo AntTask from Open Source Competence Group */
/* Creation date Wed May 11 02:01:54 PDT 2005 */
/* Creation date Tue Nov 08 14:52:44 PST 2005 */
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 1115802114846L). */
private static Date buildDate = new Date(1115802114846L);
/** buildDate (set during build process to 1131490364109L). */
private static Date buildDate = new Date(1131490364109L);
/**
* Get buildDate (set during build process to Wed May 11 02:01:54 PDT 2005).
* Get buildDate (set during build process to Tue Nov 08 14:52:44 PST 2005).
* @return Date buildDate
*/
public static final Date getBuildDate() { return buildDate; }
/**
* Get buildNumber (set during build process to 27).
* Get buildNumber (set during build process to 37).
* @return int buildNumber
*/
public static final int getBuildNumber() { return 27; }
public static final int getBuildNumber() { return 37; }
/** version (set during build process to "0.3"). */