Menu

[r26]: / scriptbot / scripts / serverquery / serverquery.js  Maximize  Restore  History

Download this file

133 lines (119 with data), 4.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// 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);
MongoDB Logo MongoDB