package roundaround.tiberius.cmd.impl;

import java.io.IOException;

import net.xeoh.plugins.base.annotations.PluginImplementation;
import roundaround.tiberius.Core;
import roundaround.tiberius.User;
import roundaround.tiberius.cmd.CommandBase;
import roundaround.tiberius.cmd.ICommandPlugin;

@PluginImplementation
public class CommandActiveBots extends CommandBase implements ICommandPlugin {

    @Override
    public String getHelp() {
        return "Returns the list of currently running bots and the channel capacity for each.";
    }

    @Override
    public String[] getAliases() {
        return new String[] { "activebots", "bots" };
    }
    
    @Override
    public void exec(User src, String chan, String cmd, String args) throws IOException {
        String list = "Current active bots: ";
        
        for (Core botInstance : Core.bots) {
            list += botInstance.getCurrNick() + "@" + botInstance.getServerConnection().getServer() + " (" + botInstance.getCurrentChannels().size() + "/40 channels); ";
        }
        
        this.getBot().getIOManager().message(chan, list);
    }
    
    @Override
    public String getCommandSet() {
        return "roundaround.tiberius.Core";
    }

}
