Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 1

Teamspeak bot is not responding

Hello everyone,

 

i have a Problem with my TS3 Bot. I code it with Java, and here is the Code of the Load-Class:

 

package eu.beeadev.Main;

import java.util.ArrayList;
import java.util.logging.Level;

import com.github.theholywaffle.teamspeak3.TS3Api;
import com.github.theholywaffle.teamspeak3.TS3Config;
import com.github.theholywaffle.teamspeak3.TS3Query;
import com.github.theholywaffle.teamspeak3.TS3Query.FloodRate;

import eu.beeadev.Event.Event;

public class Load {

public static ArrayList<String> JoinedPlayers = new ArrayList<>();
public static ArrayList<String> Supporter = new ArrayList<>();
public static ArrayList<String> Name = new ArrayList<>();
public static ArrayList<String> OnlinePlayers = new ArrayList<>();

public static final TS3Config config = new TS3Config();
public static final TS3Query query = new TS3Query(config);
public static final TS3Api api = query.getApi();

public static void main(String[] args) {
System.out.println("Loading...");
System.out.println("Connecting...");
config.setHost("192.168.178.47");
System.out.println("Loading... 10%");
config.setFloodRate(FloodRate.UNLIMITED);
System.out.println("Loading... 20%");
System.out.println("Loading... 30%");
config.setDebugLevel(Level.ALL);
System.out.println("Loading... 40%");
System.out.println("Loading... 50%");
System.out.println("Loading... 60%");
query.connect();
System.out.println("Loading... 70%");
api.login("SupportBot", "YvAjUfyS");
System.out.println("Loading... 80%");
api.selectVirtualServerById(1);
System.out.println("Loading... 90%");
api.setNickname("SupportBot");
System.out.println("Loading... 100%");
System.out.println("Loading Events...");
Event.loadEvents();
System.out.println("Bot has been started");
}
}

 

The Loading-Messages are for me to check where are Errors, but in this Class is everything fine i think.

 

The Events-Class:

 

package eu.beeadev.Event;

import java.util.HashMap;
import java.util.Map;

import com.github.theholywaffle.teamspeak3.api.ChannelProperty;
import com.github.theholywaffle.teamspeak3.api.TextMessageTargetMode;
import com.github.theholywaffle.teamspeak3.api.event.ChannelCreateEvent;
import com.github.theholywaffle.teamspeak3.api.event.ChannelDeletedEvent;
import com.github.theholywaffle.teamspeak3.api.event.ChannelDescriptionEditedEvent;
import com.github.theholywaffle.teamspeak3.api.event.ChannelEditedEvent;
import com.github.theholywaffle.teamspeak3.api.event.ChannelMovedEvent;
import com.github.theholywaffle.teamspeak3.api.event.ChannelPasswordChangedEvent;
import com.github.theholywaffle.teamspeak3.api.event.ClientJoinEvent;
import com.github.theholywaffle.teamspeak3.api.event.ClientLeaveEvent;
import com.github.theholywaffle.teamspeak3.api.event.ClientMovedEvent;
import com.github.theholywaffle.teamspeak3.api.event.PrivilegeKeyUsedEvent;
import com.github.theholywaffle.teamspeak3.api.event.ServerEditedEvent;
import com.github.theholywaffle.teamspeak3.api.event.TS3Listener;
import com.github.theholywaffle.teamspeak3.api.event.TextMessageEvent;
import com.github.theholywaffle.teamspeak3.api.wrapper.Client;

import eu.beeadev.Main.Load;

public class Event {

public static void loadEvents() {


Load.api.registerAllEvents();
Load.api.addTS3Listeners(new TS3Listener() {

@Override
public void onTextMessage(TextMessageEvent e) {
int clientid = Load.api.whoAmI().getId();
if(e.getTargetMode() == TextMessageTargetMode.CLIENT && e.getInvokerId() != clientid) {
String msg = e.getMessage().toLowerCase();
if(msg.startsWith("!support")) {
Client c = Load.api.getClientInfo(e.getInvokerId());
if(c.isInServerGroup(9)) {
if(Load.Supporter.contains(c.getUniqueIdentifier())) {
Load.Supporter.remove(c.getUniqueIdentifier());
Load.api.sendPrivateMessage(c.getId(), "Du hast dich vom Supportsystem abgemeldet");
} else {
Load.Supporter.add(c.getUniqueIdentifier());
Load.api.sendPrivateMessage(c.getId(), "Du hast dich im Supportsystem angemeldet");
if(Load.Supporter.size() <= 1) {
Map<ChannelProperty, String> options = new HashMap<>();
options.put(ChannelProperty.CHANNEL_DESCRIPTION, "[center][size=15][B]Der Support ist derzeit [COLOR=#55ff00]geöffnet[/COLOR][/B]");
options.put(ChannelProperty.CHANNEL_NAME, "Support Warteraum [Geöffnet]");
options.put(ChannelProperty.CPID, "7");
options.put(ChannelProperty.CHANNEL_MAXCLIENTS, "50");
Load.api.editChannel(7, options);
} else {
Map<ChannelProperty, String> options = new HashMap<>();
options.put(ChannelProperty.CHANNEL_DESCRIPTION, "[center][size=15][B]Der Support ist derzeit [COLOR=#ff0040]geschlossen[/COLOR][/B]");
options.put(ChannelProperty.CHANNEL_NAME, "Support Warteraum [Geschlossen]");
options.put(ChannelProperty.CPID, "7");
options.put(ChannelProperty.CHANNEL_MAXCLIENTS, "0");
Load.api.editChannel(7, options);
Load.api.editChannel(7, options);
}
}
} else {

}
} else if(msg.startsWith("!help")) {
Client c = Load.api.getClientInfo(e.getInvokerId());
Load.api.sendPrivateMessage(e.getInvokerId(), "Commands:");
if(c.isInServerGroup(9)) {
Load.api.sendPrivateMessage(c.getId(), " - '!support' um dich im Supportsystem an-/abzumelden");
} else {
Load.api.sendPrivateMessage(c.getId(), " - '!help' um diese Hilfe aufzurufen");
Load.api.sendPrivateMessage(c.getId(), " - '!help' um diese Hilfe aufzurufen");
Load.api.sendPrivateMessage(c.getId(), " - '!help' um diese Hilfe aufzurufen");
}
} else {
Client c = Load.api.getClientInfo(e.getInvokerId());
Load.api.sendPrivateMessage(c.getId(), "Schreibe '!help' für Hilfe");
}
}
}

@Override
public void onClientMoved(ClientMovedEvent e) {
if(e.getTargetChannelId() == 2) {
if(Load.Supporter.isEmpty()) {
Client c = Load.api.getClientInfo(e.getInvokerId());
Load.api.sendPrivateMessage(c.getId(), "Es sind dezeit keine Supporter online");
} else {
for(Client c : Load.api.getClients()) {
if(c.isInServerGroup(9)) {
Load.api.sendPrivateMessage(c.getId(), "Jemand wartet im Support!");
Load.api.sendPrivateMessage(e.getClientId(), "Die Supporter wurden benachrichtigt");
} else {
}
}
}
}
}

@Override
public void onChannelCreate(ChannelCreateEvent arg0) {
}

@Override
public void onChannelDeleted(ChannelDeletedEvent arg0) {
}

@Override
public void onChannelDescriptionChanged(ChannelDescriptionEditedEvent arg0) {
}

@Override
public void onChannelEdit(ChannelEditedEvent arg0) {
}

@Override
public void onChannelMoved(ChannelMovedEvent arg0) {
}

@Override
public void onChannelPasswordChanged(ChannelPasswordChangedEvent arg0) {
}

@Override
public void onClientJoin(ClientJoinEvent e) {
Client c = Load.api.getClientInfo(e.getClientId());
Load.OnlinePlayers.add(c.getUniqueIdentifier());
if(c.isInServerGroup(9)) {
Load.api.sendPrivateMessage(c.getId(), "Willkommen");
Load.api.sendPrivateMessage(c.getId(), "Schreibe '!support' um dich im Loginsystem anzumelden");
} else {
Load.api.sendPrivateMessage(c.getId(), "Willkommen");
}
}
@Override
public void onClientLeave(ClientLeaveEvent e) {
Client c = Load.api.getClientInfo(e.getClientId());
Load.OnlinePlayers.remove(c.getUniqueIdentifier());
if(c.isInServerGroup(9)) {
if(Load.Supporter.contains(c.getUniqueIdentifier())) {
Load.Supporter.remove(c.getUniqueIdentifier());
if(Load.Supporter.isEmpty()) {
Map<ChannelProperty, String> options = new HashMap<>();
options.put(ChannelProperty.CHANNEL_DESCRIPTION, "[center][size=15][B]Der Support ist derzeit [COLOR=#ff0040]geschlossen[/COLOR][/B]");
options.put(ChannelProperty.CHANNEL_NAME, "Support Warteraum [Geschlossen]");
options.put(ChannelProperty.CPID, "7");
options.put(ChannelProperty.CHANNEL_MAXCLIENTS, "0");
Load.api.editChannel(7, options);
}
} else {
}
} else {

}

}

@Override
public void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent arg0) {
}

@Override
public void onServerEdit(ServerEditedEvent arg0) {
}

});
}
}

 

 

So the Problem:

If i start the Bot he work how he has to.

He answer the Command ("!support" to login to the supportsystem) and send a Joinmessage.

To test him again i reconnect to my testserver. He send me the Joinmessage, but he answerd not to the "!support" Command. I can not login or logout, but the joinmessage works... 

If a TS3 User join or leave this Error is in the Console (i work with Eclipse if this is a problem):

[SEVERE] TS3 command error: {msg=invalid clientID, id=512}
I dont know how to fix this Error and why the Bot dont answer if i rejoin...

If you need some more Infos, just write :D

Thank you ^^

LG RobotCappu