These are chat archives for TheHolyWaffle/TeamSpeak-3-Java-API

4th
Oct 2016
kreidlerflorett
@kreidlerflorett
Oct 04 2016 17:52
Thank you! I managed it! :D
Roger Baumgartner
@rogermb
Oct 04 2016 17:53
Congrats :P
kreidlerflorett
@kreidlerflorett
Oct 04 2016 17:53
Im fascinated about the possibilitys of this api!
But which would be the best methode to create a channel and move the clients of one channel into the new created channel?
Roger Baumgartner
@rogermb
Oct 04 2016 18:49
When you call createChannel, you get back the ID of the new channel. We'll need that one later, so store it in a variable.
Next, call getClients() to get a list of all clients on the server. From that list, remove all clients that are not in the channel you're looking for. With Java 8 there's a new method called removeIf in collection classes, which does this in one step.
Next, you'll need to put the client IDs of all those clients into a new array. This step is a bit of a code sore at the moment, and this will probably not be necessary anymore in later versions.
After that, simply call moveClients with the IDs of the clients and the ID of the channel :D
Raner
@rrrepsu_twitter
Oct 04 2016 19:47
Hello is this chat where newbie questions can be asked as well :)?
Roger Baumgartner
@rogermb
Oct 04 2016 19:48
Sure :-D
Raner
@rrrepsu_twitter
Oct 04 2016 19:48
Is it okay to speak in PM? wouldnt like to clutter the main chat
Roger Baumgartner
@rogermb
Oct 04 2016 19:48
Just keep it here, it doesn't really add clutter. This chat is almost exclusively about support anyways :D
Raner
@rrrepsu_twitter
Oct 04 2016 19:52
Im student myself so i dont have that much experience with coding in general and teamspeak 3/APIs. My little project is to make TS3 bot read users input and output it in format I want. EventListener.java can do that ,correct?
also Thanks in advance for answering my questions
Roger Baumgartner
@rogermb
Oct 04 2016 19:54
I'd suggest making your listener class extends TS3EventAdapter instead of implements TS3Listener. That just keeps you from having to have empty method bodies for every event type (including the ones that don't even interest you)
To get event notifications from the server, you'll have to do 2 things:
  1. Call addTS3Listeners with your event listener and
  2. Tell the server to send you events by calling registerEvent.
Raner
@rrrepsu_twitter
Oct 04 2016 19:58
Hmmm
Roger Baumgartner
@rogermb
Oct 04 2016 19:58
If you just want the server to send you events about everything going on and don't care about "filtering", you could also just call registerAllEvents for step 2
Raner
@rrrepsu_twitter
Oct 04 2016 20:03
Sorry im quite slow haha just getting used to this API, my goal is similar to something like this (hopefully im allowed to post gyazo here) https://gyazo.com/c5e180b9a0d0ff242afbf00aa05b6807
Users type different phrases like 22 DWF etc and then server adds it to the list and essentially prints it out
or reformats it
Roger Baumgartner
@rogermb
Oct 04 2016 20:04
I have 0 clue how that's supposed to work :P
But if you have any API questions I'll quite certainly be able to help :D
Raner
@rrrepsu_twitter
Oct 04 2016 20:08

Hmm let me rephrase my questions perhaps. My basic goal is let users input info to my bot and let bot output it in another format.

Something like this:
User21: 29 DWF
User82: 123 RDI
User5: 100 ELM

and then bot would read all those inputs and output in format like this lets say:

TS3Bot:

DWF: 29
RDI: 123
ELM: 100

Of course there would be more numbers depending how many users write their info to the chat box

Im just little bit lost where should I start exactly to implement this
with help of this wonderful API
So far I've copied EventListener and ts3api java into my eclipse project
Roger Baumgartner
@rogermb
Oct 04 2016 20:11
First of all, you'll need an event listener that overrides onTextMessage. After that, you'll also need some sort of data structure to store these numbers internally. And finally you'll want to have some method that prints the content of these data structures, so you'll also need sendChannelMessage or sendServerMessage

copied EventListener

First of all, copying files is almost always the wrong thing to do. Secondly, I don't recall there being a file called EventListener. Are you sure you're not mistaken?

Raner
@rrrepsu_twitter
Oct 04 2016 20:14
Hmm I used the EventListenerExample
Roger Baumgartner
@rogermb
Oct 04 2016 20:14
Ah, alright. I don't think that's the best point to start off in your case. I'd rather go with ChatBotExample
Oh, and copying examples is ok. I thought at first you were copying internal API classes into your project :P
Raner
@rrrepsu_twitter
Oct 04 2016 20:16
Oh ,no :) Sorry if im not clear enough. I actually thought this project would be bit easier duethe nature of my goal haha
I could probably write code for it in just pure java app but mixed with TS3 I get bit lost
Roger Baumgartner
@rogermb
Oct 04 2016 20:20
So basically, for the most part your app will stay the same, but instead of System.in for input you'll need to use the chat messages provided in onTextMessage and instead of printing your messages to System.out you'll need to use sendChannelMessage :P
Is there a specific part of the API you're having difficulties with?
Raner
@rrrepsu_twitter
Oct 04 2016 20:25
First of all I'd like to say that I'm forever grateful you're answering my super noobish questions in this chat. Means world to me sir. Right now im trying to get this ChatBotExample work with my server by replacing login details in code
after that I should make it into exe file right
So it would connect to my ts server
since code already has sendChannelMessage and onTextMessage Im sure I could figure something out to reach my goal
Roger Baumgartner
@rogermb
Oct 04 2016 20:26
Uhm, in most cases you can only build your java application to a .jar file. Unless you're using some crazy native toolchain :P.
And dude, please don't call me sir. We're all programmers here, and I'm probably not even older than you. :P
No need to treat anyone differently :-D
And yeah, that's pretty much all there is to it :D
Raner
@rrrepsu_twitter
Oct 04 2016 22:11
Hmm I followed your advice, made a project, added ChatBotExample file as my test file, added teamspeak3-api-1.0.13.jar as library to the project. It actually let me export it into runnable jar file but right now its not reaching the TS server, I assume it would log in as client right. Is there perhaps someobdy in chat that you know who has tinkered with ChatBox recently? I really don't want to annoy you whole evening (=
Roger Baumgartner
@rogermb
Oct 04 2016 22:17
Just post it in the public chat, chances are good that someone else will help you if you mention it. I'll have to go to sleep now, long day tomorrow. :stuck_out_tongue:
Raner
@rrrepsu_twitter
Oct 04 2016 22:18
Alright
Thank you so much for your help!
much appreciated and have a good night
Roger Baumgartner
@rogermb
Oct 04 2016 22:19
Thanks! :smile:
Raner
@rrrepsu_twitter
Oct 04 2016 22:25
Going to wait for a response :smile: