Added version command.
This commit is contained in:
parent
26dae0eb8a
commit
64656550eb
5 changed files with 206 additions and 101 deletions
|
@ -73,13 +73,35 @@ public class Mobibot extends PircBot
|
|||
*/
|
||||
public static final int CONNECT_TIMEOUT = 5000;
|
||||
|
||||
/**
|
||||
* The HH:MM timestamp simple date format.
|
||||
*/
|
||||
private static final SimpleDateFormat HHMM_SDF = new SimpleDateFormat("HH:mm");
|
||||
|
||||
/**
|
||||
* The ISO (YYYY-MM-DD) simple date format.
|
||||
*/
|
||||
private static final SimpleDateFormat ISO_SDF = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
* The info strings.
|
||||
*/
|
||||
private static final String[] INFO_STRS = {"Mobibot v" + ReleaseInfo.getVersion() + '.'
|
||||
+ ReleaseInfo.getBuildNumber()
|
||||
+ " by Erik C. Thauvin (erik@thauvin.net)",
|
||||
"http://www.mobitopia.org/mobibot/"};
|
||||
private static final String[] INFO_STRS =
|
||||
{"Mobibot v" + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber()
|
||||
+ " by Erik C. Thauvin (erik@thauvin.net)", "http://www.mobitopia.org/mobibot/"};
|
||||
|
||||
/**
|
||||
* The version strings.
|
||||
*/
|
||||
private static final String[] VERSION_STRS =
|
||||
{"Version: " + ReleaseInfo.getVersion() + '.' + ReleaseInfo.getBuildNumber() + " ("
|
||||
+ ISO_SDF.format(ReleaseInfo.getBuildDate()) + ')',
|
||||
"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") + ')'};
|
||||
|
||||
/**
|
||||
* Debug command line argument.
|
||||
|
@ -296,6 +318,11 @@ public class Mobibot extends PircBot
|
|||
*/
|
||||
private static final String INFO_CMD = "info";
|
||||
|
||||
/**
|
||||
* The version command.
|
||||
*/
|
||||
private static final String VERSION_CMD = "version";
|
||||
|
||||
/**
|
||||
* The view command.
|
||||
*/
|
||||
|
@ -306,16 +333,6 @@ public class Mobibot extends PircBot
|
|||
*/
|
||||
public static final String WEATHER_CMD = "weather";
|
||||
|
||||
/**
|
||||
* The HH:MM timestamp simple date format.
|
||||
*/
|
||||
private static final SimpleDateFormat HHMM_SDF = new SimpleDateFormat("HH:mm");
|
||||
|
||||
/**
|
||||
* The ISO (YYYY-MM-DD) simple date format.
|
||||
*/
|
||||
private static final SimpleDateFormat ISO_SDF = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
* The start time.
|
||||
*/
|
||||
|
@ -332,6 +349,7 @@ public class Mobibot extends PircBot
|
|||
private static final int DEFAULT_PORT = 6667;
|
||||
|
||||
// Initialize the countries.
|
||||
|
||||
static
|
||||
{
|
||||
COUNTRIES_MAP.put("AU", "Australia/Sydney");
|
||||
|
@ -1048,6 +1066,14 @@ public class Mobibot extends PircBot
|
|||
send(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + SAY_CMD + " <text>"));
|
||||
}
|
||||
}
|
||||
else if (lcTopic.endsWith(VERSION_CMD))
|
||||
{
|
||||
if (isOp(sender))
|
||||
{
|
||||
send(sender, "To view the version data (bot, java, etc.):");
|
||||
send(sender, DOUBLE_INDENT + bold("/msg " + getNick() + ' ' + VERSION_CMD));
|
||||
}
|
||||
}
|
||||
else if (lcTopic.endsWith(MSG_CMD))
|
||||
{
|
||||
if (isOp(sender))
|
||||
|
@ -1085,17 +1111,21 @@ public class Mobibot extends PircBot
|
|||
DOUBLE_INDENT + bold(
|
||||
CALC_CMD + ' ' + CURRENCY_CMD + ' ' + DICE_CMD + ' ' + GOOGLE_CMD + ' ' + IGNORE_CMD));
|
||||
send(sender,
|
||||
DOUBLE_INDENT + bold(INFO_CMD + ' ' + getChannel().substring(1) + ' ' + LOOKUP_CMD + ' '
|
||||
+ HELP_POSTING_KEYWORD + ' ' + RECAP_CMD));
|
||||
DOUBLE_INDENT + bold(
|
||||
INFO_CMD + ' ' + getChannel().substring(1) + ' ' + LOOKUP_CMD + ' ' + HELP_POSTING_KEYWORD
|
||||
+ ' ' + RECAP_CMD));
|
||||
send(sender,
|
||||
DOUBLE_INDENT + bold(SPELL_CMD + ' ' + STOCK_CMD + ' ' + HELP_TAGS_KEYWORD + ' ' + TIME_CMD + ' '
|
||||
+ USERS_CMD + ' ' + VIEW_CMD));
|
||||
DOUBLE_INDENT + bold(
|
||||
SPELL_CMD + ' ' + STOCK_CMD + ' ' + HELP_TAGS_KEYWORD + ' ' + TIME_CMD + ' ' + USERS_CMD + ' '
|
||||
+ VIEW_CMD));
|
||||
send(sender, DOUBLE_INDENT + bold(JAIKU_CMD + ' ' + TWITTER_CMD + ' ' + WEATHER_CMD));
|
||||
|
||||
if (isOp(sender))
|
||||
{
|
||||
send(sender, "The op commands are:");
|
||||
send(sender, DOUBLE_INDENT + bold(CYCLE_CMD + ' ' + ME_CMD + ' ' + MSG_CMD + ' ' + SAY_CMD));
|
||||
send(sender,
|
||||
DOUBLE_INDENT + bold(
|
||||
CYCLE_CMD + ' ' + ME_CMD + ' ' + MSG_CMD + ' ' + SAY_CMD + ' ' + VERSION_CMD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1377,6 +1407,10 @@ public class Mobibot extends PircBot
|
|||
{
|
||||
infoResponse(sender, false);
|
||||
}
|
||||
else if (cmd.equals(VERSION_CMD))
|
||||
{
|
||||
versionResponse(sender, false);
|
||||
}
|
||||
else if (cmd.equals(DICE_CMD))
|
||||
{
|
||||
final Random r = new Random();
|
||||
|
@ -1918,6 +1952,10 @@ public class Mobibot extends PircBot
|
|||
{
|
||||
infoResponse(sender, true);
|
||||
}
|
||||
else if (cmd.equals(VERSION_CMD))
|
||||
{
|
||||
versionResponse(sender, true);
|
||||
}
|
||||
else if (cmd.equals(DEBUG_CMD))
|
||||
{
|
||||
if (isOp(sender))
|
||||
|
@ -2497,6 +2535,23 @@ public class Mobibot extends PircBot
|
|||
isPrivate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds with the bot's version info.
|
||||
*
|
||||
* @param sender The nick of the person who sent the message.
|
||||
* @param isPrivate Set to true is the response should be send as a private message.
|
||||
*/
|
||||
private void versionResponse(String sender, boolean isPrivate)
|
||||
{
|
||||
if (isOp(sender))
|
||||
{
|
||||
for (int i = 0; i < VERSION_STRS.length; i++)
|
||||
{
|
||||
send(sender, VERSION_STRS[i], isPrivate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified nick should be ignored.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Created by JReleaseInfo AntTask from Open Source Competence Group */
|
||||
/* Creation date Fri Apr 02 02:49:45 PDT 2010 */
|
||||
/* Creation date Mon Sep 13 14:45:55 PDT 2010 */
|
||||
package net.thauvin.erik.mobibot;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -20,21 +20,21 @@ public class ReleaseInfo {
|
|||
}
|
||||
|
||||
|
||||
/** buildDate (set during build process to 1270201785391L). */
|
||||
private static final Date buildDate = new Date(1270201785391L);
|
||||
/** buildDate (set during build process to 1284414355047L). */
|
||||
private static final Date buildDate = new Date(1284414355047L);
|
||||
|
||||
/**
|
||||
* Get buildDate (set during build process to Fri Apr 02 02:49:45 PDT 2010).
|
||||
* Get buildDate (set during build process to Mon Sep 13 14:45:55 PDT 2010).
|
||||
* @return Date buildDate
|
||||
*/
|
||||
public static Date getBuildDate() { return buildDate; }
|
||||
|
||||
|
||||
/**
|
||||
* Get buildNumber (set during build process to 4).
|
||||
* Get buildNumber (set during build process to 5).
|
||||
* @return int buildNumber
|
||||
*/
|
||||
public static int getBuildNumber() { return 4; }
|
||||
public static int getBuildNumber() { return 5; }
|
||||
|
||||
|
||||
/** project (set during build process to "mobibot"). */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue