Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.tim.ts3;
- import com.github.theholywaffle.teamspeak3.*;
- import com.github.theholywaffle.teamspeak3.api.TextMessageTargetMode;
- import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
- import com.github.theholywaffle.teamspeak3.api.wrapper.ServerGroup;
- import org.omg.Messaging.SYNC_WITH_TRANSPORT;
- import sun.awt.SunHints;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.*;
- import java.util.logging.Level;
- public class Load {
- public static final TS3Config config = new TS3Config();
- public static final TS3Query query = new TS3Query(config);
- public static final TS3Api api = query.getApi();
- public static ArrayList<Integer> NoAfkclass = new ArrayList<Integer>();
- static String nick = "undefined";
- public static String preset;
- public static String quname;
- public static String qupw;
- public static String in;
- public static String in2;
- public static Thread inputreader;
- public static Thread commands;
- public static Thread adminco;
- public static boolean cadmin;
- public static String cmsg;
- public static String[] cmsgcut;
- public static int cid;
- public static Thread setup;
- public static Thread passwdcheck;
- public static int tabblenth = 14;
- public static String[] result = new String[tabblenth+1];
- public static final int tabbelskinreg = 4;
- public static final boolean Debug_Mode = true;
- public static void main(String[]args) {
- Configssback.readMySQL();
- Msql.connect();
- Msql.createTable();
- Scanner scanner = new Scanner(System.in);
- System.out.println("Ts3 Bot by Alex \nVersion : 2.FUCKING HELL MSQL IST SHIT.1 Beta");
- System.out.print("User: ");
- preset = scanner.nextLine();
- if(preset.equals("Debug") && Debug_Mode == false){
- System.out.println("Debug Mode not enabeled");
- System.exit(56);
- }
- if(preset.equals("Debug") && Debug_Mode == true){
- getUserbyPreset(preset);
- }else{
- getUserbyPreset(preset);
- passwdcheckint();
- passwdcheck.run();
- }
- //System.out.println(result[1]);
- config.setHost(result[4]);
- config.setQueryPort(Integer.valueOf(result[5]));
- config.setDebugLevel(Level.ALL);
- query.connect();
- api.login(result[6],result[7]);
- //System.out.println(result[6]+"|"+result[7]);
- api.selectVirtualServerByPort(Integer.valueOf(result[8]));
- api.setNickname(result[9]);
- /*System.out.println("Afk channel id: ");
- AFK.afkchannel = scanner.nextInt();
- scanner.close();
- System.out.println("No Afk groups ids (getrennt mit leerzeichen): ");
- in2 = scanner.nextLine();
- //scanner2.close();
- //scanner.next();
- //Scanner scanner3 = new Scanner(System.in);
- System.out.println("Admin groups ids (getrennt mit leerzeichen): ");
- in = scanner.nextLine();
- scanner.close();*/
- //String f=scanner.next();
- //scanner.close();
- //scanner.close();
- //String in = "10 62";
- if(result[11]!=null){
- AFK.afkchannel = Integer.valueOf(result[11]);
- }
- if(result[14]!=null){
- try {
- AFK.timetomove = Integer.valueOf(result[14]);
- }catch (NumberFormatException e){
- System.out.println("[Startup] Time till move not correct set Falling back to default: 20 sec");
- }
- }else{
- System.out.println("[Startup] Time till move not set Falling back to default: 20 sec");
- }
- if(result[13]!=null){
- Boolean prevent = false;
- //System.out.println(result[13]);
- String[] input = result[13].split("&");
- if(result[12].equals("")|| result[13].equals(" ")|| input.length==0){
- prevent=true;
- //System.out.println("Crashing now");
- }
- if(prevent==false){
- for(int i = 0; i < input.length; i++){
- Chatbot.Admins.add(Integer.valueOf(input[i]));
- }
- }
- }
- if(result[12]!=null){
- Boolean prevent = false;
- //System.out.println(result[12]);
- String[] input = result[12].split("&");
- if(result[12].equals("")|| result[12].equals(" ")|| input.length==0){
- prevent=true;
- //System.out.println("Crashing now");
- }
- if(prevent==false){
- for(int i = 0; i < input.length; i++){
- //Chatbot.Admins.add(Integer.valueOf(input[i]));
- NoAfkclass.add(Integer.valueOf(input[i]));
- }
- }
- }
- /*
- if(in2!=null){
- Boolean prevent = false;
- Boolean one = false;
- String[] input2 = in2.split(" ");
- if(in.equals("")|| in.equals(" ")|| input2.length==0){
- prevent=true;
- //System.out.println("Crashing now");
- }
- int fuck = 0;
- try{
- fuck = Integer.valueOf(in2);
- if(fuck != 0){
- one = true;
- }
- }catch (NumberFormatException e ){
- System.out.println("aids"+in2+"|"+in);
- }
- if(prevent==false){
- System.out.println("adding"+in2);
- for(int i = 0; i < input2.length; i++){
- NoAfkclass.add(Integer.valueOf(input2[i]));
- }
- }
- if(one ==true){
- NoAfkclass.add(Integer.valueOf(in2));
- }
- }*/
- Events.loadEvents();
- System.out.println("[Startup] Events Loaded");
- AFK.start();
- System.out.println("[Startup] Afk bot Loaded");
- Chatbot.start();
- Threads.admincom();
- System.out.println("[Startup] Chatbot Loaded");
- for(Client c : Load.api.getClients()){
- for(int i = 0;i < c.getServerGroups().length; i++){
- for (int z = 0; z < Chatbot.Admins.size(); z++) {
- if(c.getServerGroups()[i] == Chatbot.Admins.get(z)){
- Chatbot.Admin.put(c.getUniqueIdentifier(),true);
- //System.out.println("got admin " + c.getNickname());
- }
- }
- }
- }
- System.out.println("[Startup]Got all curent admins");
- Threads.inputreader();
- Threads.commands();
- inputreader.run();
- Threads.Case();
- System.out.println("[Startup] Threads started");
- System.out.println("[Startup]Done loading");
- /*for(int i = 0;i<NoAfkclass.size();i++){
- System.out.println(NoAfkclass.get(i));
- }*/
- }
- public static void passwdcheckint(){
- passwdcheck = new Thread(new Runnable() {
- @Override
- public void run() {
- System.out.print("Password: ");
- Scanner scanner = new Scanner(System.in);
- String pw = scanner.nextLine();
- if(pw.equals(result[2])){
- if(result[3].equals("1")){
- System.out.println("logging in");
- }else{
- System.out.println("You acount has been disabeled");
- }
- }else{
- System.out.println("password not found");
- System.exit(88);
- }
- }
- });
- }
- public static String[] getUserbyPreset(String preset){
- try {
- PreparedStatement st = Msql.con.prepareStatement("SELECT * FROM users WHERE username= ?");
- st.setString(1,preset);
- ResultSet rs = st.executeQuery();
- result = null;
- result = new String[tabblenth+1];
- while (rs.next()){
- for(int i = 0;i<tabblenth;i++){
- int z = i+1;
- String ear = rs.getString(z);
- result[z] = ear;
- }
- }
- if(result[1]==null){
- System.out.println("User not found");
- System.exit(88);
- }else{
- return result;
- }
- }catch (SQLException e){
- e.printStackTrace();
- }
- return null;
- }
- /*public static void main(String[]args){
- Configs.setStandardMySQL();
- Configs.readMySQL();
- Msql.connect();
- Msql.createTable();
- Scanner scanner = new Scanner(System.in);
- System.out.println("Ts3 Bot by Alex \nVersion : 1.03");
- System.out.print("User: ");
- preset = scanner.nextLine();
- if(!(preset.equalsIgnoreCase("alextest"))){
- System.out.print("Quarry Login username: ");
- quname = scanner.nextLine();
- System.out.print("Quarry Login password: ");
- qupw = scanner.nextLine();
- System.out.print("Time till movein sec: ");
- AFK.timetomove = scanner.nextInt();
- System.out.print("Afk channel id: ");
- AFK.afkchannel = scanner.nextInt();
- System.out.print("Bot nickname (min 3 zeichen): ");
- nick = scanner.nextLine();
- nick = scanner.nextLine();
- System.out.println("No Afk groups ids (getrennt mit leerzeichen): ");
- in2 = scanner.nextLine();
- System.out.println("Admin groups ids (getrennt mit leerzeichen): ");
- in = scanner.nextLine();
- //scanner.close();
- }
- //String in = "10 62";
- if(in!=null){
- String[] input = in.split(" ");
- for(int i = 0; i < input.length; i++){
- Chatbot.Admins.add(Integer.valueOf(input[i]));
- }
- }
- if(in2!=null){
- String[] input2 = in2.split(" ");
- for(int i = 0; i < input2.length; i++){
- NoAfkclass.add(Integer.valueOf(input2[i]));
- }
- }
- //System.out.print("[Debug] got " + quname + "|" + qupw);
- //NoAfkclass.add(37);
- //NoAfkclass.add(12);
- //Debug("Name");
- if(preset.equalsIgnoreCase("kugelhd")){
- Stephan(nick,quname,qupw);
- }
- if(preset.equalsIgnoreCase("alex")){
- Debug(nick,quname,qupw);
- }
- if(preset.equalsIgnoreCase("alextest")){
- AFK.timetomove = 360;
- AFK.afkchannel = 29;
- Chatbot.Admins.add(27);
- Chatbot.Admins.add(10);
- NoAfkclass.add(12);
- NoAfkclass.add(37);
- Debug("Test Bot","Bot","8sBn8UZf");
- }
- if(preset.equalsIgnoreCase("debug")){
- System.out.print("Server ip: ");
- String ip = scanner.nextLine();
- config.setHost(ip);
- System.out.print("Quarry Port: ");
- int port = scanner.nextInt();
- config.setQueryPort(port);
- config.setDebugLevel(Level.ALL);
- query.connect();
- api.login(quname,qupw);
- System.out.print("Server Port: ");
- int sport = scanner.nextInt();
- api.selectVirtualServerByPort(sport);
- System.out.print("Bot nickname: ");
- String nickname = scanner.nextLine();
- api.setNickname(nickname);
- }
- Events.loadEvents();
- System.out.println("[Startup] Events Loaded");
- AFK.start();
- System.out.println("[Startup] Afk bot Loaded");
- Chatbot.start();
- System.out.println("[Startup] Chatbot Loaded");
- for(Client c : Load.api.getClients()){
- for(int i = 0;i < c.getServerGroups().length; i++){
- for (int z = 0; z < Chatbot.Admins.size(); z++) {
- if(c.getServerGroups()[i] == Chatbot.Admins.get(z)){
- Chatbot.Admin.put(c.getUniqueIdentifier(),true);
- //System.out.println("got admin " + c.getNickname());
- }
- }
- }
- }
- System.out.println("[Startup]Got all curent admins");
- Threads.inputreader();
- Threads.commands();
- inputreader.run();
- System.out.println("[Startup] Threads started");
- System.out.println("[Startup]Done loading");
- Msql.connect();
- //Msql.checkTabel();
- }*/
- public static Boolean msg = false;
- public static String input = "";
- public static int msgid = 0;
- public static void sendmsg(int id, String message){
- Load.api.pokeClient(id,message);
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,id,message);
- System.out.println("[Commands handler] send " + message +" too " + Load.api.getClientInfo(id).getNickname());
- msg = false;
- }
- public static class Threads{
- public static void inputreader(){
- inputreader = new Thread(new Runnable() {
- @Override
- public void run() {
- Timer inputreader = new Timer();
- inputreader.schedule(new TimerTask() {
- @Override
- public void run() {
- final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- try {
- input = br.readLine();
- if(!(input.equals(""))){
- if(!msg){
- commands.run();
- }else{
- if(!(msgid == 0)){
- sendmsg(msgid,input);
- }
- }
- }
- } catch (IOException e){
- }
- }
- },100,100);
- }
- });
- }
- public static void commands(){
- commands = new Thread(new Runnable() {
- @Override
- public void run() {
- String read = input;
- if(read.equals("help")){
- String help= "";
- help = "[Commands handler]";
- //help = help+"\nclear : leert den globalen chat(nur so na ja)";
- help = help+"\nnick : ändert nen nickmanen des botes";
- help = help+"\nadmins reload : reloaded alle admins";
- help = help+"\nadmins get : zeigt alle admin gruppen ids an";
- help = help+"\nadmins add/remove : fügt admin gruppen zu der liste hinzu und entfert sie von der liste";
- help = help+"\ngetclients : zeigt alle nutzer an";
- help = help+"\nmsg schreibt einem spieler";
- help = help+"\nmove : (client id(bekommt man wenn mann !getclients macht) (channel id)";
- help = help+"\nexit : Moveed alle auf afk raus und beendent den bot";
- help = help+"\nunafk : not done";
- help = help+"\nafk : not done";
- //help = help+"\nÄh ka?";
- System.out.println(help);
- }
- if(read.equals("admins " + "reload")){
- //System.out.println("reload");
- Chatbot.Admin.clear();
- for(Client c : Load.api.getClients()){
- if(!(c.isServerQueryClient())) {
- for (int i = 0; i < c.getServerGroups().length; i++) {
- for (int z = 0; z < Chatbot.Admins.size(); z++) {
- if (c.getServerGroups()[i] == Chatbot.Admins.get(z) || c.getUniqueIdentifier().equals("QZnglCRxAPiWl2rALb3zVJsL+rk=")) {
- //if(!(Admin.containsKey(c.getUniqueIdentifier()))){
- //System.out.println("got admin " + c.getNickname());
- //}
- Chatbot.Admin.put(c.getUniqueIdentifier(), true);
- }
- }
- }
- }
- }
- System.out.println("[Commands handler] Done");
- }
- if(read.equalsIgnoreCase("getclients")){
- String list = "";
- List<Client> cs = api.getClients();
- int lenth =0;
- for(Client c : cs){
- if(!(c.isServerQueryClient())){
- if(!(list.equalsIgnoreCase(""))){
- list=list+", ";
- }
- list=list+c.getNickname() +"|" + c.getId();
- lenth++;
- }
- }
- System.out.println("[Commands handler] Total Clients: "+ lenth);
- System.out.println("[Commands handler] List: " + list);
- }
- if(read.startsWith("admins " + "remove")) {
- String[]msgcut = read.split(" ");
- //if (Admin.containsKey(Load.api.getClientInfo(id).getUniqueIdentifier())) {
- //System.out.println("remove");
- int offset = 2;
- int lenth = msgcut.length - offset;
- String eee = "";
- for (int y = 0; y < lenth; y++) {
- int yy = y + offset;
- // System.out.println(msg2[yy]);
- // if()
- if (eee.equalsIgnoreCase("")) {
- eee = msgcut[yy];
- } else {
- eee = eee + " " + msgcut[yy];
- }
- }
- if (Chatbot.Admins.contains(Integer.valueOf(eee))) {
- Chatbot.Admins.remove(Integer.valueOf(eee));
- System.out.println("[Commands handler] Removed " + eee + " aus der Admin ids list");
- } else {
- System.out.println("[Commands handler] Nicht in der Admin ids list");
- }
- //}else{
- //Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,id,"[color=red] keine rechte");
- //}
- }
- if(read.startsWith("admins " + "add")){
- String[]msgcut = read.split(" ");
- int offset = 2;
- int lenth = msgcut.length - offset;
- String eee = "";
- for (int y = 0; y < lenth; y++) {
- int yy = y + offset;
- // System.out.println(msg2[yy]);
- // if()
- if (eee.equalsIgnoreCase("")) {
- eee = msgcut[yy];
- } else {
- eee = eee + " " + msgcut[yy];
- }
- }
- if (!(Chatbot.Admins.contains(Integer.valueOf(eee)))) {
- Chatbot.Admins.add(Integer.valueOf(eee));
- System.out.println("[Commands handler] Added " + eee + " zu der Admin ids list");
- } else {
- System.out.println("[Commands handler] Ist schon auf der liste");
- }
- }
- if(read.equals("admins " + "get")){
- //System.out.println("get");
- String list= "";
- for (int z = 0; z < Chatbot.Admins.size(); z++) {
- list = list+Chatbot.Admins.get(z)+" ";
- }
- System.out.println("[Commands handler] " + list);
- }
- if(read.startsWith("nick")) {
- String[]msgcut = read.split(" ");
- int offset = 1;
- int lenth = msgcut.length - offset;
- String eee = "";
- for (int y = 0; y < lenth; y++) {
- int yy = y + offset;
- // System.out.println(msg2[yy]);
- // if()
- if (eee.equalsIgnoreCase("")) {
- eee = msgcut[yy];
- } else {
- eee = eee + " " + msgcut[yy];
- }
- }
- if(eee.length() >2){
- Load.api.setNickname(eee);
- System.out.println("[Commands handler] set nickname to " + eee);
- }else{
- System.out.println("[Commands handler] to short");
- }
- }
- if(read.startsWith("msg")){
- String[] msgcut = read.split(" ");
- int offset = 1;
- int lenth = msgcut.length - offset;
- String eee = "";
- for (int y = 0; y < lenth; y++) {
- int yy = y + offset;
- // System.out.println(msg2[yy]);
- // if()
- if (eee.equalsIgnoreCase("")) {
- eee = msgcut[yy];
- } else {
- eee = eee + " " + msgcut[yy];
- }
- }
- int msguser = 0;
- int ergebnis = 0;
- for(Client c : Load.api.getClients()){
- if(!(c.isServerQueryClient())){
- //System.out.println(c.getNickname() + "|" + eee);
- if (eee.toLowerCase().contains(c.getNickname().toLowerCase()) || eee.toLowerCase().equals(c.getNickname().toLowerCase()) || c.getNickname().toLowerCase().contains(eee.toLowerCase())) {
- msguser = c.getId();
- ergebnis++;
- }
- }
- }
- if(ergebnis > 1 ){
- System.out.println("[Commands handler] found too many users (max 1)");
- }else{
- if(ergebnis == 1){
- if(msguser!=0){
- msg = true;
- msgid = msguser;
- //kasokdokaopwkdwaowiofioajwegijioeghuoiedrhguiojrhguiorhgshueighueighuisghuisehgfiueshguziesghbzuesghziusezhgesdgzhifeghbzidfasgwbehifrgbaiszhegbfvizhaegfbvrizuhawgbvfrziawgvizhfrvgbaiwzfrvgbizavbgfr
- System.out.print("Nachricht: ");
- }
- }else{
- if(ergebnis == 0){
- System.out.println("[Commands handler] found no users");
- }
- }
- }
- }
- if(read.startsWith("exit")){
- for(Client c : Load.api.getClients()){
- Long time = c.getIdleTime() / 1000;
- for(int i = 0;i<AFK.Moved.size();i++){
- //System.out.println(c.getUniqueIdentifier()+"%"+ AFK.Moved.get(c.getUniqueIdentifier()));
- }
- if (AFK.Moved.get(c.getUniqueIdentifier()) != null) {
- //System.out.println("moveing out");
- if(!(AFK.Second.containsKey(c.getUniqueIdentifier()))) {
- System.out.println(c.getNickname() + " moved out of afk" + " " + time);
- AFK.Moved.remove(c.getUniqueIdentifier());
- System.out.println(c.getId()+"|"+ AFK.Channel.get(c.getUniqueIdentifier()));
- Load.api.moveClient(c.getId(), AFK.Channel.get(c.getUniqueIdentifier()));
- AFK.Channel.remove(c.getUniqueIdentifier());
- }else{
- AFK.Second.remove(c.getUniqueIdentifier());
- System.out.println(c.getNickname() + " moved out of afk_schild" + " " + time);
- AFK.Moved.remove(c.getUniqueIdentifier());
- Load.api.moveClient(c.getId(), AFK.Channel.get(c.getUniqueIdentifier()));
- AFK.Channel.remove(c.getUniqueIdentifier());
- }
- }
- }
- System.exit(88);
- }
- if(read.startsWith("unafk"))
- if(read.startsWith("move")){
- //System.out.println("1");
- String[] msgcut = read.split(" ");
- //int msgcut2 = Integer.parseInt(msgcut[1]);
- if(Integer.parseInt(msgcut[1]) > 0){
- //System.out.println("2" + msgcut.length);
- if(Integer.parseInt(msgcut[2]) > 0){
- //System.out.println("3");
- Load.api.moveClient(Integer.parseInt(msgcut[1]),Integer.parseInt(msgcut[2]));
- }else{
- System.out.println("int clientId, int channelId");
- }
- }else{
- System.out.println("int clientId, int channelId");
- }
- }
- }
- });
- }
- public static void admincom(){
- adminco = new Thread(new Runnable() {
- @Override
- public void run() {
- if(Load.cmsg.equals("!admins " + "reload")){
- //System.out.println("reload");
- Chatbot.Admin.clear();
- for(Client c : Load.api.getClients()){
- if(!(c.isServerQueryClient())) {
- for (int i = 0; i < c.getServerGroups().length; i++) {
- for (int z = 0; z < Chatbot.Admins.size(); z++) {
- if(Chatbot.Alex){
- if (c.getServerGroups()[i] == Chatbot.Admins.get(z) || c.getUniqueIdentifier().equals("QZnglCRxAPiWl2rALb3zVJsL+rk=")) {
- Chatbot.Admin.put(c.getUniqueIdentifier(), true);
- }
- }else{
- if (c.getServerGroups()[i] == Chatbot.Admins.get(z)) {
- Chatbot.Admin.put(c.getUniqueIdentifier(), true);
- }
- }
- }
- }
- }
- }
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,Load.cid,"[color=green] Done");
- }
- if(Load.cmsg.startsWith("!admins " + "remove")) {
- if (Chatbot.Admin.containsKey(Load.api.getClientInfo(Load.cid).getUniqueIdentifier())) {
- //System.out.println("remove");
- int offset = 2;
- int lenth = Load.cmsgcut.length - offset;
- String eee = "";
- for (int y = 0; y < lenth; y++) {
- int yy = y + offset;
- // System.out.println(Load.cmsg2[yy]);
- // if()
- if (eee.equalsIgnoreCase("")) {
- eee = Load.cmsgcut[yy];
- } else {
- eee = eee + " " + Load.cmsgcut[yy];
- }
- }
- if (Chatbot.Admins.contains(Integer.valueOf(eee))) {
- Chatbot.Admins.remove(Integer.valueOf(eee));
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT, Load.cid, "[color=green] Removed " + eee + " aus der Chatbot.Admin Load.cids list");
- } else {
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT, Load.cid, "[color=red] Nicht in der Chatbot.Admin Load.cids list");
- }
- }else{
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,Load.cid,"[color=red] keine rechte");
- }
- }
- if(Load.cmsg.startsWith("!admins " + "add")){
- if(!(Chatbot.Admin.containsKey(Load.api.getClientInfo(Load.cid).getUniqueIdentifier()))){
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,Load.cid,"[color=red] keine rechte");
- }else {
- //System.out.println("add");
- int offset = 2;
- int lenth = Load.cmsgcut.length - offset;
- String eee = "";
- for (int y = 0; y < lenth; y++) {
- int yy = y + offset;
- // System.out.println(Load.cmsg2[yy]);
- // if()
- if (eee.equalsIgnoreCase("")) {
- eee = Load.cmsgcut[yy];
- } else {
- eee = eee + " " + Load.cmsgcut[yy];
- }
- }
- if (!(Chatbot.Admins.contains(Integer.valueOf(eee)))) {
- Chatbot.Admins.add(Integer.valueOf(eee));
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT, Load.cid, "[color=green] Added " + eee + " zu der Chatbot.Admin Load.cids list");
- } else {
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT, Load.cid, "[color=red] Ist schon auf der liste");
- }
- }
- }
- if(Load.cmsg.equals("!admins " + "get")){
- //System.out.println("get");
- String list= "";
- for (int z = 0; z < Chatbot.Admins.size(); z++) {
- list = list+Chatbot.Admins.get(z)+" ";
- }
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,Load.cid,"[color=green]" + list);
- if(Chatbot.Admin.containsKey(Load.api.getClientInfo(Load.cid).getUniqueIdentifier())){
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,Load.cid,"[color=green]" + "you are admin");
- }else{
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,Load.cid,"[color=green]" + "you no admin");
- }
- }
- }
- });
- }
- public static void Case(){
- Chatbot.Case = new Thread(new Runnable() {
- @Override
- public void run() {
- if(cmsg.startsWith("!case help")){
- String help = "[color=green]";
- help = help+"\n!case help: zeigt dir das an";
- help = help+"\n!case get <CaseID>: Das Case zu der Id an";
- help = help+"\n!case add <CaseID> <User> <Bet 1/0> <Amount>: Das Case zu der Id an";
- help = help+"\n!case user <User>: Zeigt alle Cases für den User an";
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,help);
- }
- if(cmsg.startsWith("!case user")){
- if(cmsgcut.length == 3){
- //System.out.println("test");
- String User = cmsgcut[2];
- try {
- PreparedStatement st = Msql.con.prepareStatement("SELECT * FROM `skincases` WHERE User=? AND Activ_Bet=?");
- st.setString(1,User);
- st.setString(2,"0");
- ResultSet rs = st.executeQuery();
- while (rs.next()){
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,getCasebyId(Integer.valueOf(rs.getString("Case_Id")))[2]+" * "+rs.getString("Amount")+" for "+getCasebyId(Integer.valueOf(rs.getString("Case_Id")))[3]+"$");
- //System.out.println(getCasebyId(Integer.valueOf(rs.getString("Case_Id")))[2]+" * "+rs.getString("Amount")+" for "+getCasebyId(Integer.valueOf(rs.getString("Case_Id")))[3]+"$"));
- }
- }catch (SQLException eeeee){
- eeeee.printStackTrace();
- }
- }
- }
- if(cmsg.startsWith("!case add")){
- int case_id = 99;
- Boolean valid = true;
- try {
- case_id = Integer.valueOf(cmsgcut[2]);
- }catch (NumberFormatException e){
- try {
- }catch (NullPointerException ee){
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,addColor("red")+"Case not found in database");
- }
- //Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,"Case: "+addColor("gold")+tesa[0]+addColor("white")+addColor("white")+" ID: "+addColor("blue")+tesa[1]+addColor("white")+" Cost: "+addColor("green")+getCasebyId(Integer.valueOf(tesa[1]))[3]+"$");
- }
- if(valid && case_id<50){
- //System.out.println("od");
- int kill = 0;
- try {
- kill = Integer.valueOf(cmsgcut[5]);
- }catch (NumberFormatException eeee){
- }
- if(getCasebyId(case_id)[1]!= null){
- //case got
- if(kill != 0) {
- if (cmsgcut[4].equalsIgnoreCase("1") || cmsgcut[4].equalsIgnoreCase("0")) {
- try {
- //System.out.println("Suck");
- PreparedStatement preparedStatement = Msql.con.prepareStatement("INSERT INTO `skincases`(`User`, `Case_id`, `Activ_Bet`, `Amount`) VALUES (?,?,?,?)");
- preparedStatement.setString(1, cmsgcut[3]);
- preparedStatement.setString(2, case_id + "");
- preparedStatement.setString(3, cmsgcut[4]);
- preparedStatement.setString(4,kill+"");
- preparedStatement.executeUpdate();
- } catch (SQLException eee) {
- eee.printStackTrace();
- }
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,addColor("green")+"Succesfully added User: "+ cmsgcut[3]+ " Case_ID: "+ case_id+" Bet: "+ cmsgcut[4]+" Amount: "+ kill);
- } else {
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT, cid, addColor("red") + "!case add <CaseID> <User> <Bet 1/0> <Amount>: Das Case zu der Id an");
- }
- }
- }else{
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,addColor("red")+"Case not found in database");
- }
- }
- }
- if(cmsg.startsWith("!case get")){
- //System.out.println("Start");
- int case_id = 99;
- Boolean valid = true;
- try {
- case_id = Integer.valueOf(cmsgcut[2]);
- }catch (NumberFormatException e){
- valid = false;
- //System.out.println("not");
- String[] tesa = getCasebyNae(cmsgcut[2]);
- try {
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,"Case: "+addColor("gold")+tesa[0]+addColor("white")+addColor("white")+" ID: "+addColor("blue")+tesa[1]+addColor("white")+" Cost: "+addColor("green")+getCasebyId(Integer.valueOf(tesa[1]))[3]+"$");
- }catch (NullPointerException ee){
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,addColor("red")+"Case not found in database");
- }
- //Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,"Case: "+addColor("gold")+tesa[0]+addColor("white")+addColor("white")+" ID: "+addColor("blue")+tesa[1]+addColor("white")+" Cost: "+addColor("green")+getCasebyId(Integer.valueOf(tesa[1]))[3]+"$");
- }
- if(valid && case_id<50){
- //System.out.println("od");
- if(getCasebyId(case_id)[1]!= null){
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,"Case: "+addColor("gold")+getCasebyId(case_id)[2]+addColor("white")+addColor("white")+" ID: "+addColor("blue")+getCasebyId(case_id)[1]+addColor("white")+" Cost: "+addColor("green")+getCasebyId(case_id)[3]+"$");
- }else{
- System.out.println("null");
- Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,addColor("red")+"Case not found in database");
- }
- }
- }
- }
- });
- }
- }
- public static String[] getCasebyNae(String name){
- //System.out.println(name);
- String[] res = new String[2];
- try {
- PreparedStatement st = Msql.con.prepareStatement("SELECT * FROM `skincases_register`");
- ResultSet rs = st.executeQuery();
- while (rs.next()){
- //String l = rs.getString("Name");
- //System.out.println(l+"|"+rs.getString("Id"));
- if(name.equalsIgnoreCase(rs.getString("Name")) || rs.getString("Name").toLowerCase().startsWith(name)){
- res[0] = rs.getString("Name");
- res[1] = rs.getString("Id");
- return res;
- }
- //Load.api.sendTextMessage(TextMessageTargetMode.CLIENT,cid,l+"|"+rs.getString("Id"));
- }
- }catch (SQLException e){
- e.printStackTrace();
- }
- return null;
- }
- public static String[] getCasebyId(int Case_id){
- String reur[] = new String[tabbelskinreg];
- try {
- PreparedStatement st = Msql.con.prepareStatement("SELECT * FROM skincases_register WHERE Id= ?");
- st.setString(1,Case_id+"");
- ResultSet rs = st.executeQuery();
- while (rs.next()){
- for(int i = 1;i<tabbelskinreg;i++){
- int z = i;
- String ear = rs.getString(z);
- reur[z] = ear;
- //System.out.println(ear+"|"+z);
- }
- }
- if(reur[2]==null){
- return null;
- }else{
- return reur;
- }
- }catch (SQLException e){
- e.printStackTrace();
- }
- return null;
- }
- public static String addColor(String Color){
- return "[color="+Color+"]";
- }
- //public static String removeColor(String Color){
- //}
- public static void Debug(String nick,String user, String pw){
- config.setHost("192.168.0.228");
- config.setQueryPort(10011);
- config.setDebugLevel(Level.ALL);
- query.connect();
- api.login(user,pw);
- api.selectVirtualServerByPort(9987);
- api.setNickname(nick);
- }
- public static void Stephan(String nick,String user, String pw){
- config.setHost("46.20.46.232");
- config.setQueryPort(10011);
- config.setDebugLevel(Level.ALL);
- query.connect();
- api.login(user,pw);
- api.selectVirtualServerByPort(10056);
- api.setNickname(nick);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement