// event handlers
// commands
command = factory.getBean("command");
command.setName("querygs");
command.setRegex("(?:q|f|qf)\\b");
command.setDescription("Shows information about the server such as game type, map, and number of players.");
command.setUsage("[ <shortcut> | <game type> <address:port> ]");
//command.setArgCount(0);
//command.setSplitArgs(false);
command.addInput("channel");
command.addInput("private");
command.addInput("notice");
command.addInput("dcc");
command.setScript("commands/querygs.js");
//command.addGroup(REGISTERED);
command.setModule(module);
bot.registerCommand(command);
command = factory.getBean("command");
command.setName("games");
command.setDescription("Shows a list of supported games.");
//command.setUsage("");
command.setArgCount(0);
//command.setSplitArgs(false);
command.addInput("channel");
command.addInput("private");
command.addInput("notice");
command.addInput("dcc");
command.setScript("commands/games.js");
//command.addGroup(REGISTERED);
command.setModule(module);
bot.registerCommand(command);
command = factory.getBean("command");
command.setName("addgs");
command.setDescription("Adds a shortcut to a game server. This makes it easier to query a server as it is then stored by a short name rather than full ip and port");
command.setUsage("<shortcut> <game type> <address:port>");
command.setArgCount(3);
//command.setSplitArgs(false);
command.addInput("channel");
command.addInput("private");
command.addInput("notice");
command.addInput("dcc");
command.setScript("commands/addgs.js");
command.addGroup(MASTER);
command.setModule(module);
bot.registerCommand(command);
command = factory.getBean("command");
command.setName("removegs");
command.setDescription("This removes a shortcut permanently from the list");
command.setUsage("<shortcut>");
command.setArgCount(1);
//command.setSplitArgs(false);
command.addInput("channel");
command.addInput("private");
command.addInput("notice");
command.addInput("dcc");
command.setScript("commands/removegs.js");
command.addGroup(MASTER);
command.setModule(module);
bot.registerCommand(command);
command = factory.getBean("command");
command.setName("adddefaultgs");
command.setDescription("Adds a default game server. The list of default server is queried when no shortcut or server address is given to the query commands.");
command.setUsage("<shortcut> <game type> <address:port>");
command.setArgCount(3);
//command.setSplitArgs(false);
command.addInput("channel");
command.addInput("private");
command.addInput("notice");
command.addInput("dcc");
command.setScript("commands/adddefaultgs.js");
command.addGroup(MASTER);
command.setModule(module);
bot.registerCommand(command);
// initialisation
var defaultSevers;
if (!persistence.exists(module, "defaultServers")) {
defaultServers = new java.util.HashMap();
persistence.save(defaultServers, module, "defaultServers");
} else {
defaultServers = persistence.load(module, "defaultServers");
}
var shortcuts;
if (!persistence.exists(module, "shortcuts")) {
shortcuts = new java.util.HashMap();
persistence.save(shortcuts, module, "shortcuts");
} else {
shortcuts = persistence.load(module, "shortcuts");
}
var queryPort;
if (!persistence.exists(module, "queryPort")) {
queryPort = 27778;
persistence.save(queryPort, module, "queryPort");
} else {
queryPort = persistence.load(module, "queryPort");
}
var serverFormat;
if (!persistence.exists(module, "serverFormat")) {
var fmt = "$DARK_GREEN$name$NORMAL :: IP: $UNDERLINE$ip:$port$NORMAL :: $game :: $BLUE$map$NORMAL :: Players: $players/$maxplayers";
persistence.save(fmt, module, "serverFormat");
} else {
serverFormat = persistence.load(module, "serverFormat");
}
importPackage(Packages.net.sourceforge.queried);
var supportedGames = "";
var i = QueriEd.getSupportedGames().keySet().iterator();
var comma = false;
while (i.hasNext()) {
if(comma) {
supportedGames += ", ";
} else {
comma = true;
}
supportedGames += i.next();
}
bot.putInCache(module + ".supportedGames", supportedGames);
bot.putInCache(module + ".shortcuts", shortcuts);
bot.putInCache(module + ".defaultServers", defaultServers);
bot.putInCache(module + ".queryPort", queryPort);
bot.putInCache(module + ".serverFormat", serverFormat);