package net.acomputerdog.ircbot.core.command;

import com.sorcix.sirc.structure.Channel;
import com.sorcix.sirc.structure.User;
import com.sorcix.sirc.util.Chattable;
import net.acomputerdog.ircbot.command.Command;
import net.acomputerdog.ircbot.command.util.CommandLine;
import net.acomputerdog.ircbot.main.IrcBot;
import net.acomputerdog.ircbot.plugin.IrcPlugin;
import net.acomputerdog.ircbot.plugin.PluginList;

public class CommandStatus extends Command {
    public CommandStatus(IrcBot bot) {
        super(bot, "Status", "status", "stats");
    }

    @Override
    public String getDescription() {
        return "Gets the internal status of AcomputerBot.";
    }

    @Override
    public boolean processCommand(Channel channel, User sender, Chattable target, CommandLine command) {
        target.send(bot.getVersionString() + " status:");
        target.send("  " + bot.getCommandManager().getCommandNameMap().size() + " loaded commands with " + bot.getCommandManager().getCommandMap().size() + " registered aliases.");
        target.send("  Memory: " + (Runtime.getRuntime().freeMemory() / 1000000) + "mb used / " + (Runtime.getRuntime().totalMemory() / 1000000) + "mb allocated / " + (Runtime.getRuntime().maxMemory() / 1000000) + "mb available.");
        PluginList plugins = bot.getPluginList();
        StringBuilder builder = new StringBuilder(plugins.size() * 2);
        int count = 0;
        for (IrcPlugin plugin : plugins.getPlugins()) {
            if (count > 0) {
                builder.append(", ");
            }
            builder.append(plugin.getID());
            count++;
        }
        target.send("  Plugins (" + plugins.size()  + "): " + builder.toString());
        return true;
    }
}

@@ -160,16 +160,106 @@
 ttable;%0A
+import net.acomputerdog.core.time.ITime;%0Aimport net.acomputerdog.core.time.StandardClock;%0A
 import n
@@ -544,16 +544,52 @@
 mmand %7B%0A
+%0A    private final long startTime;%0A%0A
     publ
@@ -664,24 +664,73 @@
 , %22stats%22);%0A
+        startTime = System.currentTimeMillis();%0A%0A
     %7D%0A%0A    @
@@ -1883,19 +1883,421 @@
     
-return true
+target.send(%22  Uptime: %22 + calcUptime());%0A        return true;%0A    %7D%0A%0A    private String calcUptime() %7B%0A        long millis = System.currentTimeMillis() - startTime;%0A        long seconds = millis / 1000;%0A        long minutes = seconds / 60;%0A        long hours = minutes / 60;%0A        long days = hours / 24;%0A        return days + %22 days, %22 + hours + %22 hours, %22 + minutes + %22 minutes, and %22 + seconds + %22 seconds.%22
 ;%0A  

Add uptime to CommandStatus