From 43488447469d8f61b93984e93ef3fbc8340eead3 Mon Sep 17 00:00:00 2001 From: getPoland Date: Sat, 12 Nov 2022 01:15:50 +0100 Subject: [PATCH] Alpha-v1.3.2 * Improvements | + Added | - Removed * Small improvements + fliter for a specific name in ServerJoinEvent --- .../crackscout123/Events/SeverJoinEvent.java | 9 +- src/de/crackscout123/Main/CrackysBot.java | 2 +- src/de/crackscout123/Utils/NicknameCheck.java | 31 ++++ src/de/crackscout123/Utils/sys.java | 2 +- .../crackscout123/Verify/VerifyCommand.java | 166 ++++++++++++++++++ src/de/crackscout123/Wrapper/Debug.java | 2 +- 6 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 src/de/crackscout123/Utils/NicknameCheck.java create mode 100644 src/de/crackscout123/Verify/VerifyCommand.java diff --git a/src/de/crackscout123/Events/SeverJoinEvent.java b/src/de/crackscout123/Events/SeverJoinEvent.java index aec8f5d..88a9d96 100644 --- a/src/de/crackscout123/Events/SeverJoinEvent.java +++ b/src/de/crackscout123/Events/SeverJoinEvent.java @@ -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 { @@ -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) {} diff --git a/src/de/crackscout123/Main/CrackysBot.java b/src/de/crackscout123/Main/CrackysBot.java index 28e8f36..f501bb2 100644 --- a/src/de/crackscout123/Main/CrackysBot.java +++ b/src/de/crackscout123/Main/CrackysBot.java @@ -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(); diff --git a/src/de/crackscout123/Utils/NicknameCheck.java b/src/de/crackscout123/Utils/NicknameCheck.java new file mode 100644 index 0000000..722761f --- /dev/null +++ b/src/de/crackscout123/Utils/NicknameCheck.java @@ -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 + * + */ \ No newline at end of file diff --git a/src/de/crackscout123/Utils/sys.java b/src/de/crackscout123/Utils/sys.java index ccfd9c9..cf201d1 100644 --- a/src/de/crackscout123/Utils/sys.java +++ b/src/de/crackscout123/Utils/sys.java @@ -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."; diff --git a/src/de/crackscout123/Verify/VerifyCommand.java b/src/de/crackscout123/Verify/VerifyCommand.java new file mode 100644 index 0000000..bae2d6f --- /dev/null +++ b/src/de/crackscout123/Verify/VerifyCommand.java @@ -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 + * + */ \ No newline at end of file diff --git a/src/de/crackscout123/Wrapper/Debug.java b/src/de/crackscout123/Wrapper/Debug.java index 9cabe08..08f68fc 100644 --- a/src/de/crackscout123/Wrapper/Debug.java +++ b/src/de/crackscout123/Wrapper/Debug.java @@ -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); } }