Skip to content

Commit

Permalink
Alpha-v1.3.2
Browse files Browse the repository at this point in the history
* Improvements | + Added | - Removed

* Small improvements

+ fliter for a specific name in ServerJoinEvent
  • Loading branch information
crackscout123 committed Nov 12, 2022
1 parent ae02470 commit 4348844
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/de/crackscout123/Events/SeverJoinEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.github.theholywaffle.teamspeak3.api.wrapper.Client;

import de.crackscout123.Main.CrackysBot;
import de.crackscout123.Wrapper.Debug;

public class SeverJoinEvent {

Expand All @@ -29,15 +30,19 @@ public static void load() {
@Override
public void onClientJoin(ClientJoinEvent e) {
sender = CrackysBot.api.getClientByUId(e.getUniqueClientIdentifier());
System.out.println("|debug| "+ sender.getNickname() + " joined the server.");

//check Nickname
if(e.getClientNickname().contains("56e34fcv")) {
CrackysBot.api.kickClientFromServer("not allowed username!", e.getClientId());
}

Debug.info(sender.getNickname() + " joined the server.");


}

@Override
public void onTextMessage(TextMessageEvent args0) { }
public void onTextMessage(TextMessageEvent args0) {}

@Override
public void onChannelCreate(ChannelCreateEvent arg0) {}
Expand Down
2 changes: 1 addition & 1 deletion src/de/crackscout123/Main/CrackysBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CrackysBot {
public static void main(String[] args) {
Debug.info("STARTING BOT!");
// load defaults
//VerifyCommand.createDefaults();
// VerifyCommand.createDefaults();

ChannelAlertEvent.createDefaults();
AfkMoveEvent.createDefaults();
Expand Down
31 changes: 31 additions & 0 deletions src/de/crackscout123/Utils/NicknameCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.crackscout123.Utils;

import com.github.theholywaffle.teamspeak3.api.wrapper.Client;

import de.crackscout123.Wrapper.Config;

public class NicknameCheck {
// Initialize variables
public static Client sender;
public static Client target;
public static String file = "badNicknames.yml";

public static void createDefaults() {
if(!Config.checkForDefault(file)) {
Config.saveProp("path", "value", file);
}
}

public static void load(Client c) {

}

}


/**
* @author Joel Rzepka - crackscout123.de
*
* @date 11.11.2022 - 23:42:49
*
*/
2 changes: 1 addition & 1 deletion src/de/crackscout123/Utils/sys.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class sys {
public static String hostname = CrackysBot.args_host;
public static String query_user = CrackysBot.args_user;
public static String query_pass = CrackysBot.args_pass;
public static Integer VirtualServerId = 1;
public static Integer VirtualServerId = 2;
public static String nickname = CrackysBot.args_nickname;

public static String msg_botrunning = "Hi %sender%. All my system are online and running.";
Expand Down
166 changes: 166 additions & 0 deletions src/de/crackscout123/Verify/VerifyCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
package de.crackscout123.Verify;

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 de.crackscout123.Main.CrackysBot;
import de.crackscout123.Wrapper.Config;

public class VerifyCommand {

public static Client sender;
public static Client target;
public static String file = "Verify.app";

// Create verify.app
public static void createDefaults() {
if(!Config.checkForDefault(file)) {
Config.saveProp("verifiedGroup", "26", file);
Config.saveProp("verifyEnabled", "false", file);
Config.saveProp("poke", "true", file);
Config.saveProp("notificationMsg", "[color=red]You need to verify yourself - use !verify", file);
Config.saveProp("verifiedMsg", "[color=green]Successfully verified!", file);
}
}

public static void load() {

Integer verifiedGroup = Integer.parseInt(Config.loadProp("verifiedGroup", file));
Boolean verifyEnabled = Boolean.parseBoolean(Config.loadProp("verifyEnabled", file));

Boolean poke = Boolean.parseBoolean(Config.loadProp("poke", file));

String notificationMsg = Config.loadProp("notificationMsg", file);
//String verifiedMsg = Config.loadProp("verifiedMsg", file);

CrackysBot.api.registerAllEvents();
CrackysBot.api.addTS3Listeners(new TS3Listener[] { new TS3Listener(){

@Override
public void onClientJoin(ClientJoinEvent e) {

sender = CrackysBot.api.getClientByUId(e.getUniqueClientIdentifier());

if(verifyEnabled) {
for(int i = 0; i < sender.getServerGroups().length; i++) {
// check if sender is already verified
if(sender.getServerGroups()[i] != verifiedGroup) {
// notify sender to verify his self
if(poke) {
CrackysBot.api.pokeClient(sender.getId(), notificationMsg);
}else {
CrackysBot.api.sendPrivateMessage(sender.getId(), notificationMsg);
}
}
}
}
}


@Override
public void onTextMessage(TextMessageEvent e) {

sender = CrackysBot.api.getClientByUId(e.getInvokerUniqueId());

if(e.getMessage().startsWith("!verify")) {
// catch the message and split in to single strings (args)
String[] args = e.getMessage().split(" ");
for(int i = 0; i < args.length; i++) {
if(args.length == 0) {
// 1. generate a verify-code
// 2. save this code in combination with ClientId() to a database?
} else {
@SuppressWarnings("unused")
String key = args[1];
//
}

}
}

}

@Override
public void onChannelCreate(ChannelCreateEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onChannelDeleted(ChannelDeletedEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onChannelDescriptionChanged(ChannelDescriptionEditedEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onChannelEdit(ChannelEditedEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onChannelMoved(ChannelMovedEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onChannelPasswordChanged(ChannelPasswordChangedEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onClientLeave(ClientLeaveEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onClientMoved(ClientMovedEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void onServerEdit(ServerEditedEvent arg0) {
// TODO Auto-generated method stub

}

}});

}
}


/**
* @author Joel Rzepka - crackscout123.de
*
* @date 25.10.2021 - 00:34:00
*
*/
2 changes: 1 addition & 1 deletion src/de/crackscout123/Wrapper/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void info(String msg) {
public static void err(String msg) {
if(debug) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.err.println(timestamp + " |DEBUG| " + msg);
System.err.println(timestamp + " |ERROR| " + msg);
}
}

Expand Down

0 comments on commit 4348844

Please sign in to comment.