TheHolyWaffle / TeamSpeak-3-Java-API

A Java wrapper of TeamSpeak's 3 server query API.
MIT License
306 stars 107 forks source link

Theholywaffle API bug with my bot #296

Closed manuelp73 closed 5 years ago

manuelp73 commented 5 years ago

When I start the bot comes this error message:

2018-12-11 21:46:33.833 [DEBUG] TS3 command error: {msg=connection failed, you are banned, extra_msg=you may retry in 456 seconds, id=3329}
Exception in thread "main" com.github.theholywaffle.teamspeak3.api.exception.TS3CommandFailedException: A command returned with a server error.
2018-12-11 21:46:33.838 [ERROR] Connection closed by the server.
connection failed, you are banned (ID 3329): you may retry in 456 seconds
    at com.github.theholywaffle.teamspeak3.api.CommandFuture.checkForFailure(CommandFuture.java:414)
    at com.github.theholywaffle.teamspeak3.api.CommandFuture.getUninterruptibly(CommandFuture.java:355)
    at com.github.theholywaffle.teamspeak3.TS3Api.login(TS3Api.java:2924)
    at at.Map_der_echte.Main.Load.main(Load.java:17)
2018-12-11 21:46:33.841 [ERROR] [Connection] Disconnected from TS3 server

What have I done wrong?

rogermb commented 5 years ago

You almost certainly set the flood rate to UNLIMITED without being whitelisted. This caused the API to send commands too quickly, which is why the TS3 server banned you.

If you want to use the UNLIMITED flood rate, you first need to add the IP of your server query client to the query_ip_whitelist.txt file in the root directory of your TS3 server. More details about that whitelist can be found on page 6 of the server query manual, which you can also find in your TS3 install directory at docs/ts3_serverquery_manual.pdf. 😃

manuelp73 commented 5 years ago

And how should I change the FloodRate?

rogermb commented 5 years ago

Huh, so you didn't change the flood rate and got banned using the default settings? How strange!

Anyway, you need to use ts3Config.setFloodRate to set the flood rate to anything other than the 350ms-per-command default value. There's FloodRate.UNLIMITED, which means no delay between commands at all (but you really need to be whitelisted), or FloodRate.custom(delayInMilliseconds) for when your TS3 server uses some custom flood rate settings.

manuelp73 commented 5 years ago

Ok, I've done it now.

If the code is correct, it will not work for me:

@Override
public void onClientJoin(ClientJoinEvent clij) {
Client c = api.getClientInfo(clij.getClientId());
api.sendPrivateMessage(c.getId(), "Herzlich Wilkommen " + c.getNickname() + " auf dem TS3 Server.");
  }
rogermb commented 5 years ago

This code looks correct. What about it doesn't work? Is there anything in the log file about it?

manuelp73 commented 5 years ago

The bot works but the text is not output.

rogermb commented 5 years ago

Did you add your listener using TS3Api#addTS3Listeners(TS3Listener) and register the events e.g. using TS3Api#registerAllEvents()?