From d750f9685ca8748e7e256e88216c3485a9d834c1 Mon Sep 17 00:00:00 2001 From: Manevolent Date: Tue, 5 Mar 2019 11:04:54 -0500 Subject: [PATCH 1/3] Setting description, editing client properties --- .../client/LocalTeamspeakClientSocket.java | 36 +++++++++++++++++++ .../manevolent/ts3j/ServerConnectionTest.java | 2 ++ 2 files changed, 38 insertions(+) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java index 0607929..6b48bc2 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java @@ -831,6 +831,42 @@ public class LocalTeamspeakClientSocket return executeCommand(banCommand, command -> new Ban(command.toMap())).get(); } + public void setDescription(String description) + throws InterruptedException, ExecutionException, TimeoutException, CommandException, IOException { + setClientDescription(getClientId(), description); + } + + public void setClientDescription(Client client, String description) + throws InterruptedException, ExecutionException, TimeoutException, CommandException, IOException { + setClientDescription(client.getId(), description); + } + + public void setClientDescription(int clid, String description) + throws InterruptedException, ExecutionException, TimeoutException, CommandException, IOException { + editClient(clid, Collections.singletonMap("client_description", description)); + } + + public void editClient(Client client, Map properties) + throws InterruptedException, ExecutionException, TimeoutException, CommandException, IOException { + editClient(client.getId(), properties); + } + + public void editClient(int clid, Map properties) + throws InterruptedException, ExecutionException, TimeoutException, CommandException, IOException { + MultiCommand command = new MultiCommand( + "clientedit", + ProtocolRole.CLIENT, + properties.entrySet().stream().map(x -> + new SingleCommand("clientedit", ProtocolRole.CLIENT, // name is redundant here + new CommandSingleParameter(x.getKey(), x.getValue()) + )).collect(Collectors.toList() + )); + + command.add(new CommandSingleParameter("clid", Integer.toString(clid))); + + executeCommand(command).complete(); + } + public Iterable banClient(Client client, Integer timeInSeconds, String reason) throws InterruptedException, ExecutionException, TimeoutException, CommandException, IOException { return banClient(client.getId(), timeInSeconds, reason); diff --git a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java index 6c1aa0e..d00d377 100644 --- a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java +++ b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java @@ -26,6 +26,8 @@ public class ServerConnectionTest { assertEquals(client.getState(), ClientConnectionState.CONNECTED); + client.setDescription("Heyo"); + client.subscribeAll(); Thread.sleep(100000); From 43ea437f6067a61c1e594988c5ac113a9346e706 Mon Sep 17 00:00:00 2001 From: sump pump Date: Wed, 15 May 2019 20:21:52 -0400 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2f836ce..31d857f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Discord: https://discord.gg/4q9jpCa TS3J is an open-source implementation of the reverse-engineered Teamspeak3 full server/client protocol, as an adaptation of Splamy's C# TS3Client source code. You can find that here: https://github.com/Splamy/TS3AudioBot/. +This project is the network-level API library for the reference implementation of Teamspeak3 for **Manebot**, my multiplatform chatbot that you can extend with your own plugins. GitHub: https://github.com/Manevolent/manebot-ts3 + A standalone proof-of-concept was created to wrap ts3j: https://github.com/Manevolent/ts3j-musicbot (Shameless plug) If you want to deliver a great music bot, check out ffmpeg4j, a wrapper around the native C library FFmpeg, to get insanely low CPU usage on your YouTube video downloads (or streams if you don't want to hit disk), and audio playback: From 361521297ac36397291113bd41a9f02e7b5e7312 Mon Sep 17 00:00:00 2001 From: sump pump Date: Wed, 29 May 2019 10:45:33 -0400 Subject: [PATCH 3/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 31d857f..e24cb37 100644 --- a/README.md +++ b/README.md @@ -121,3 +121,5 @@ public byte[] provide() { Refer to the `setVoiceHandler` and `setWhisperHandler` methods to supply a Consumer object to receive Voice and Whisper packets. You will need to decode the packets yourself, and insert packet-loss-correction as needed. Note that the first 5 packets starting a voice session are marked with the COMPRESSED flag. The final voice packet, intended to singal to close your decoder and flush samples, is always empty (0-length byte array). + +Manebot can do this in its TS3 plugin, which uses TS3j: https://github.com/Manevolent/manebot-ts3/tree/master/src/main/java/io/manebot/plugin/ts3/platform/audio/voice