Added more details to info command.
This commit is contained in:
parent
3f0c9102cd
commit
86fdde261d
8 changed files with 124 additions and 86 deletions
|
@ -13,8 +13,8 @@ import java.util.Date;
|
||||||
* Annotation Processor</a>
|
* Annotation Processor</a>
|
||||||
*/
|
*/
|
||||||
public final class ReleaseInfo {
|
public final class ReleaseInfo {
|
||||||
private final static String buildmeta = "004";
|
private final static String buildmeta = "006";
|
||||||
private final static Date date = new Date(1467595869139L);
|
private final static Date date = new Date(1467669326019L);
|
||||||
private final static int major = 0;
|
private final static int major = 0;
|
||||||
private final static int minor = 7;
|
private final static int minor = 7;
|
||||||
private final static int patch = 0;
|
private final static int patch = 0;
|
||||||
|
|
|
@ -135,7 +135,6 @@ final class Commands
|
||||||
*/
|
*/
|
||||||
public static final String SAY_CMD = "say";
|
public static final String SAY_CMD = "say";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The users command.
|
* The users command.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -925,7 +925,7 @@ public class Mobibot extends PircBot
|
||||||
send(sender, "To list the users present on the channel:");
|
send(sender, "To list the users present on the channel:");
|
||||||
send(sender, helpIndent(getNick() + ": " + Commands.USERS_CMD));
|
send(sender, helpIndent(getNick() + ": " + Commands.USERS_CMD));
|
||||||
}
|
}
|
||||||
else if (lcTopic.equals(Commands.INFO_CMD) && isOp(sender))
|
else if (lcTopic.equals(Commands.INFO_CMD))
|
||||||
{
|
{
|
||||||
send(sender, "To view information about the bot:");
|
send(sender, "To view information about the bot:");
|
||||||
send(sender, helpIndent(getNick() + ": " + Commands.INFO_CMD));
|
send(sender, helpIndent(getNick() + ": " + Commands.INFO_CMD));
|
||||||
|
@ -1019,7 +1019,7 @@ public class Mobibot extends PircBot
|
||||||
|
|
||||||
sb.append(commandsList.get(i));
|
sb.append(commandsList.get(i));
|
||||||
|
|
||||||
// 5 commands per line or last command
|
// 6 commands per line or last command
|
||||||
if (sb.length() > 0 && (cmdCount == 6 || i == (commandsList.size() - 1)))
|
if (sb.length() > 0 && (cmdCount == 6 || i == (commandsList.size() - 1)))
|
||||||
{
|
{
|
||||||
send(sender, helpIndent(sb.toString()));
|
send(sender, helpIndent(sb.toString()));
|
||||||
|
@ -1033,8 +1033,8 @@ public class Mobibot extends PircBot
|
||||||
{
|
{
|
||||||
send(sender, "The op commands are:");
|
send(sender, "The op commands are:");
|
||||||
send(sender,
|
send(sender,
|
||||||
helpIndent(Commands.CYCLE_CMD + " " + Commands.INFO_CMD + " " + Commands.ME_CMD + " "
|
helpIndent(Commands.CYCLE_CMD + " " + Commands.ME_CMD + " " + Commands.MSG_CMD + " "
|
||||||
+ Commands.MSG_CMD + " " + Commands.SAY_CMD + " " + Commands.VERSION_CMD));
|
+ Commands.SAY_CMD + " " + Commands.VERSION_CMD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1119,29 +1119,68 @@ public class Mobibot extends PircBot
|
||||||
{
|
{
|
||||||
if (info.startsWith("http://"))
|
if (info.startsWith("http://"))
|
||||||
{
|
{
|
||||||
send(sender, Utils.green(info), isPrivate);
|
send(sender, Utils.green(info), isPrivate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
send(sender, info, isPrivate);
|
send(sender, info, isPrivate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final StringBuilder info = new StringBuilder("Uptime: ");
|
||||||
|
|
||||||
long timeInSeconds = (System.currentTimeMillis() - START_TIME) / 1000L;
|
long timeInSeconds = (System.currentTimeMillis() - START_TIME) / 1000L;
|
||||||
|
|
||||||
|
final long years = timeInSeconds / 31540000L;
|
||||||
|
|
||||||
|
if (years > 0)
|
||||||
|
{
|
||||||
|
info.append(years).append(Utils.plural(years, " year ", " years "));
|
||||||
|
timeInSeconds -= (years * 31540000L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final long weeks = timeInSeconds / 604800L;
|
||||||
|
|
||||||
|
if (weeks > 0)
|
||||||
|
{
|
||||||
|
info.append(weeks).append(Utils.plural(weeks, " week ", " weeks "));
|
||||||
|
timeInSeconds -= (weeks * 604800L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
final long days = timeInSeconds / 86400L;
|
final long days = timeInSeconds / 86400L;
|
||||||
timeInSeconds -= (days * 86400L);
|
|
||||||
|
if (days > 0)
|
||||||
|
{
|
||||||
|
info.append(days).append(Utils.plural(days, " day ", " days "));
|
||||||
|
timeInSeconds -= (days * 86400L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
final long hours = timeInSeconds / 3600L;
|
final long hours = timeInSeconds / 3600L;
|
||||||
timeInSeconds -= (hours * 3600L);
|
|
||||||
|
if (hours > 0)
|
||||||
|
{
|
||||||
|
info.append(hours).append(Utils.plural(hours, " hour ", " hours "));
|
||||||
|
timeInSeconds -= (hours * 3600L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
final long minutes = timeInSeconds / 60L;
|
final long minutes = timeInSeconds / 60L;
|
||||||
|
|
||||||
send(sender,
|
info.append(minutes).append(Utils.plural(minutes, " minute ", " minutes "));
|
||||||
"Uptime: " + days + Utils.plural(days, " day ", " days ") + hours + Utils.plural(hours, " hour ", " hours ")
|
|
||||||
+ minutes + Utils.plural(minutes, " minute ", " minutes ") + "[Entries: " + entries.size()
|
info.append("[Entries: ").append(entries.size());
|
||||||
+ (tell.isEnabled() && isOp(sender) ? ", Messages: " + tell.size() : "") + ']',
|
|
||||||
isPrivate);
|
if (tell.isEnabled() && isOp(sender))
|
||||||
|
{
|
||||||
|
info.append(", Messages: ").append(tell.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
info.append(']');
|
||||||
|
|
||||||
|
send(sender, info.toString(), isPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -216,7 +216,8 @@ public class Tell
|
||||||
bot.send(sender,
|
bot.send(sender,
|
||||||
bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + TELL_DEL_KEYWORD + " <id|"
|
bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + TELL_DEL_KEYWORD + " <id|"
|
||||||
+ TELL_ALL_KEYWORD + '>'));
|
+ TELL_ALL_KEYWORD + '>'));
|
||||||
bot.send(sender, "Messages are kept for " + Utils.bold(maxDays) + Utils.plural(maxDays, " day.", " days."));
|
bot.send(sender,
|
||||||
|
"Messages are kept for " + Utils.bold(maxDays) + Utils.plural(maxDays, " day.", " days."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,16 +46,16 @@ import java.util.Calendar;
|
||||||
*/
|
*/
|
||||||
final public class Utils
|
final public class Utils
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The timestamp simple date format.
|
|
||||||
*/
|
|
||||||
public static final SimpleDateFormat TIMESTAMP_SDF = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ISO (YYYY-MM-DD) simple date format.
|
* The ISO (YYYY-MM-DD) simple date format.
|
||||||
*/
|
*/
|
||||||
public static final SimpleDateFormat ISO_SDF = new SimpleDateFormat("yyyy-MM-dd");
|
public static final SimpleDateFormat ISO_SDF = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp simple date format.
|
||||||
|
*/
|
||||||
|
public static final SimpleDateFormat TIMESTAMP_SDF = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The UTC (yyyy-MM-dd HH:mm) simple date format.
|
* The UTC (yyyy-MM-dd HH:mm) simple date format.
|
||||||
*/
|
*/
|
||||||
|
@ -245,46 +245,6 @@ final public class Utils
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current Internet (beat) Time.
|
|
||||||
*
|
|
||||||
* @return The Internet Time string.
|
|
||||||
*/
|
|
||||||
public static String internetTime()
|
|
||||||
{
|
|
||||||
final Calendar gc = Calendar.getInstance();
|
|
||||||
|
|
||||||
final int offset = (gc.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000));
|
|
||||||
int hh = gc.get(Calendar.HOUR_OF_DAY);
|
|
||||||
final int mm = gc.get(Calendar.MINUTE);
|
|
||||||
final int ss = gc.get(Calendar.SECOND);
|
|
||||||
|
|
||||||
hh -= offset; // GMT
|
|
||||||
hh += 1; // BMT
|
|
||||||
|
|
||||||
long beats = Math.round(Math.floor((double) ((((hh * 3600) + (mm * 60) + ss) * 1000) / 86400)));
|
|
||||||
|
|
||||||
if (beats >= 1000)
|
|
||||||
{
|
|
||||||
beats -= (long) 1000;
|
|
||||||
}
|
|
||||||
else if (beats < 0)
|
|
||||||
{
|
|
||||||
beats += (long) 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (beats < 10)
|
|
||||||
{
|
|
||||||
return ("@00" + beats);
|
|
||||||
}
|
|
||||||
else if (beats < 100)
|
|
||||||
{
|
|
||||||
return ("@0" + beats);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ('@' + String.valueOf(beats));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> if the given string is <em>not</em> blank or null.
|
* Returns <code>true</code> if the given string is <em>not</em> blank or null.
|
||||||
*
|
*
|
||||||
|
@ -310,12 +270,12 @@ final public class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the plural form of a word, if count > 1.
|
* Returns the plural form of a word, if count > 1.
|
||||||
*
|
*
|
||||||
* @param count The count.
|
* @param count The count.
|
||||||
* @param word The word.
|
* @param word The word.
|
||||||
* @param plural The plural word.
|
* @param plural The plural word.
|
||||||
*/
|
*/
|
||||||
public static String plural(final long count, final String word, final String plural)
|
public static String plural(final long count, final String word, final String plural)
|
||||||
{
|
{
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
|
@ -326,7 +286,7 @@ final public class Utils
|
||||||
{
|
{
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the given string reverse color.
|
* Makes the given string reverse color.
|
||||||
|
|
|
@ -71,20 +71,6 @@ final public class Twitter extends AbstractModule
|
||||||
properties.put(TOKEN_SECRET_PROP, "");
|
properties.put(TOKEN_SECRET_PROP, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled()
|
|
||||||
{
|
|
||||||
for (final String s : getPropertyKeys())
|
|
||||||
{
|
|
||||||
if (!Utils.isValidString(properties.get(s)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
|
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
|
||||||
{
|
{
|
||||||
|
@ -114,6 +100,20 @@ final public class Twitter extends AbstractModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
for (final String s : getPropertyKeys())
|
||||||
|
{
|
||||||
|
if (!Utils.isValidString(properties.get(s)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts to twitter.
|
* Posts to twitter.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
package net.thauvin.erik.mobibot.modules;
|
package net.thauvin.erik.mobibot.modules;
|
||||||
|
|
||||||
import net.thauvin.erik.mobibot.Mobibot;
|
import net.thauvin.erik.mobibot.Mobibot;
|
||||||
import net.thauvin.erik.mobibot.Utils;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
@ -166,7 +165,7 @@ final public class WorldTime extends AbstractModule
|
||||||
{
|
{
|
||||||
if (tz.equals(BEATS_KEYWORD))
|
if (tz.equals(BEATS_KEYWORD))
|
||||||
{
|
{
|
||||||
response = ("The current Internet Time is: " + Utils.internetTime() + ' ' + BEATS_KEYWORD);
|
response = ("The current Internet Time is: " + internetTime() + ' ' + BEATS_KEYWORD);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -198,6 +197,46 @@ final public class WorldTime extends AbstractModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current Internet (beat) Time.
|
||||||
|
*
|
||||||
|
* @return The Internet Time string.
|
||||||
|
*/
|
||||||
|
private String internetTime()
|
||||||
|
{
|
||||||
|
final Calendar gc = Calendar.getInstance();
|
||||||
|
|
||||||
|
final int offset = (gc.get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000));
|
||||||
|
int hh = gc.get(Calendar.HOUR_OF_DAY);
|
||||||
|
final int mm = gc.get(Calendar.MINUTE);
|
||||||
|
final int ss = gc.get(Calendar.SECOND);
|
||||||
|
|
||||||
|
hh -= offset; // GMT
|
||||||
|
hh += 1; // BMT
|
||||||
|
|
||||||
|
long beats = Math.round(Math.floor((double) ((((hh * 3600) + (mm * 60) + ss) * 1000) / 86400)));
|
||||||
|
|
||||||
|
if (beats >= 1000)
|
||||||
|
{
|
||||||
|
beats -= (long) 1000;
|
||||||
|
}
|
||||||
|
else if (beats < 0)
|
||||||
|
{
|
||||||
|
beats += (long) 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (beats < 10)
|
||||||
|
{
|
||||||
|
return ("@00" + beats);
|
||||||
|
}
|
||||||
|
else if (beats < 100)
|
||||||
|
{
|
||||||
|
return ("@0" + beats);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ('@' + String.valueOf(beats));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
|
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,4 +5,4 @@ version.major=0
|
||||||
version.minor=7
|
version.minor=7
|
||||||
version.patch=0
|
version.patch=0
|
||||||
version.prerelease=beta
|
version.prerelease=beta
|
||||||
version.buildmeta=004
|
version.buildmeta=006
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue