Finding Channel ID's in new versions of TS

Started by Sno, March 08, 2013, 01:02:11 PM

Previous topic - Next topic

Sno

Since the new versions of TS don't seem to have anywhere that displays the channel ID # (and not even a serverquery window in the client) I had been finding them by logging in an old client that does show them. But now the newest server version won't let older clients connect, so finding those #'s for config purposes is impossible with a standard client. So I wrote function for the bot that tells the bot's admin those numbers that you might want to include. Here's the code:
Add this to JTS3ServerMod.handleChatMessage():

} else if (msg.toLowerCase().startsWith("!channels")) {
chatCommands.handleChannels(eventInfo);


And stick this somewhere in ChatCommands.java:
void handleChannels(HashMap<String, String> eventInfo) {
modClass.addLogEntry("COMMAND", "Got command from " + eventInfo.get("invokername"), false);
Vector<HashMap<String, String>> channelList = queryLib.getList(JTS3ServerQuery.LISTMODE_CHANNELLIST);
StringBuilder msg = new StringBuilder(1023);
Integer lastPid = 0;
Integer newPid;
Integer indent = 0;
Vector<Integer> indentLvls = new Vector<Integer>(10);
for (HashMap<String, String> channel : channelList) {
msg.append("\n");
newPid = Integer.parseInt(channel.get("pid"));
if (newPid == 0) {
indent = 0;
indentLvls.clear();
} else if (newPid > lastPid) {
indentLvls.add(newPid);
indent++;
} else if (newPid < lastPid) {
indent = indentLvls.indexOf(newPid) + 1;
indentLvls.setSize(indent);
}
lastPid = newPid;
if (indent > 0) {
for (int i = 0; i < indent; i++) {
msg.append("\t");
}
}
msg.append(channel.get("channel_name") + ": " + channel.get("cid"));
if (msg.length() + 42 + indent > 1023) {
queryLib.sendTextMessage(Integer.parseInt(eventInfo.get("invokerid")), JTS3ServerQuery.TEXTMESSAGE_TARGET_CLIENT, msg.toString());
msg = new StringBuilder(1023);
}
}
if (msg.length() > 0)
queryLib.sendTextMessage(Integer.parseInt(eventInfo.get("invokerid")), JTS3ServerQuery.TEXTMESSAGE_TARGET_CLIENT, msg.toString());
}


Now bot admins can get a nicely formatted list of the channels with their ID's which are needed to config many of the bot's functions by messaging the bot with "!channels".
Cheers  8)

Stefan1200

#1
You can also use different Themes. As an example this one is able to show the channel id: http://addons.teamspeak.com/directory/addon/result/Extended-Client-Info.html

Stefan1200

Just to let you know: Since some month the JTS3ServerMod has the chat command !channellist / !getchannelid which accepts the channel id and the channel name.