Skip to content

Commit 8fbc6bc

Browse files
committed
dev-0.1.2
added two commands to the Admin greeting (StackedEvents.java) added new eventClass (Connections.java) prepared and started building a word filter (WordFilterMManager.java) beautifying (*)
1 parent e1d6012 commit 8fbc6bc

File tree

6 files changed

+217
-12
lines changed

6 files changed

+217
-12
lines changed

.classpath

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<attribute name="module" value="true"/>
77
</attributes>
88
</classpathentry>
9-
<classpathentry exported="true" kind="lib" path="D:/Dev/apis/teamspeak3-api-1.3.1-with-dependencies.jar"/>
9+
<classpathentry kind="lib" path="D:/Dev/apis/teamspeak3-api-1.3.1-with-dependencies.jar"/>
10+
<classpathentry kind="lib" path="C:/Users/rzepk/IdeaProjects/Ptero4J/out/artifacts/Ptero4J_jar/Ptero4J.jar"/>
1011
<classpathentry kind="output" path="bin"/>
1112
</classpath>

AdminBot/blacklisted_words.app

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#Sat Jun 10 00:18:32 CEST 2023 - still under development, this feature will be added next release // words are phrased line by line
2+
enabled=true
3+
penis
4+
muschi
5+
arsch

src/de/crackscout/AdminBot/Main.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
import com.github.theholywaffle.teamspeak3.TS3Api;
55
import com.github.theholywaffle.teamspeak3.TS3Config;
66
import com.github.theholywaffle.teamspeak3.TS3Query;
7-
87
import de.crackscout.Collectors.AfkCollector;
98
import de.crackscout.Collectors.KickCollector;
109
import de.crackscout.Commands.Clear;
1110
import de.crackscout.Commands.KickMe;
1211
import de.crackscout.Commands.Ping;
1312
import de.crackscout.Commands.Stats;
1413
import de.crackscout.Commands.Stay;
15-
import de.crackscout.Events.StackedEvents;
14+
import de.crackscout.Events.Connections;
1615
import de.crackscout.Events.Disconnect;
16+
import de.crackscout.Events.StackedEvents;
1717
import de.crackscout.Logging.Logging;
1818
import de.crackscout.Managers.AuthManager;
1919
import de.crackscout.Managers.Debug;
20+
import de.crackscout.Managers.WordFilterManager;
2021

2122

2223
public class Main {
@@ -34,7 +35,7 @@ public class Main {
3435
// java adminbot.jar "hostname" "serverID" "username:password" -debug
3536

3637
public static void main(String[] args) {
37-
38+
3839
registerLogging();
3940

4041
Debug.info("Bot loading.");
@@ -47,6 +48,7 @@ public static void main(String[] args) {
4748
credentials = args[2].split(":"); //credentials[0] = user | credentials[1] = auth
4849
username = credentials[0];
4950
password = credentials[1];
51+
5052

5153
if(args.length == 4) {
5254
if(args[3].contains("debug")) {
@@ -66,17 +68,34 @@ public static void main(String[] args) {
6668
api = query.getApi();
6769
api.login(username, password);
6870
api.selectVirtualServerById(serverID);
69-
api.setNickname("AdminBot");
71+
api.setNickname("AdminBot dev");
72+
73+
74+
registerWordFilter();
75+
Debug.info("WordFilter: registerd.");
76+
77+
registerLogging();
78+
Debug.info("Logging: registerd.");
7079

7180
registerCollectors();
72-
81+
Debug.info("Collectors: registerd.");
82+
7383
registerCommands();
84+
Debug.info("Commands: registerd.");
85+
86+
registerAuth();
87+
Debug.info("Auth: registerd.");
7488

7589
Debug.info("Bot loaded.");
7690

77-
registerAuth();
7891
}
7992

93+
94+
private static void registerWordFilter() {
95+
WordFilterManager.createDefaults();
96+
}
97+
98+
8099
private static void registerAuth() {
81100
AuthManager.createDefaults();
82101
AuthManager.readKeys();
@@ -98,6 +117,7 @@ private static void registerCommands() {
98117

99118
//events
100119
Disconnect.load();
120+
Connections.load();
101121
StackedEvents.load();
102122

103123

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package de.crackscout.Events;
2+
3+
import com.github.theholywaffle.teamspeak3.TS3Api;
4+
import com.github.theholywaffle.teamspeak3.api.event.ChannelCreateEvent;
5+
import com.github.theholywaffle.teamspeak3.api.event.ChannelDeletedEvent;
6+
import com.github.theholywaffle.teamspeak3.api.event.ChannelDescriptionEditedEvent;
7+
import com.github.theholywaffle.teamspeak3.api.event.ChannelEditedEvent;
8+
import com.github.theholywaffle.teamspeak3.api.event.ChannelMovedEvent;
9+
import com.github.theholywaffle.teamspeak3.api.event.ChannelPasswordChangedEvent;
10+
import com.github.theholywaffle.teamspeak3.api.event.ClientJoinEvent;
11+
import com.github.theholywaffle.teamspeak3.api.event.ClientLeaveEvent;
12+
import com.github.theholywaffle.teamspeak3.api.event.ClientMovedEvent;
13+
import com.github.theholywaffle.teamspeak3.api.event.PrivilegeKeyUsedEvent;
14+
import com.github.theholywaffle.teamspeak3.api.event.ServerEditedEvent;
15+
import com.github.theholywaffle.teamspeak3.api.event.TS3Listener;
16+
import com.github.theholywaffle.teamspeak3.api.event.TextMessageEvent;
17+
import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
18+
19+
import de.crackscout.AdminBot.Main;
20+
import de.crackscout.Managers.WordFilterManager;
21+
22+
public class Connections {
23+
24+
static TS3Api api = Main.api;
25+
26+
public static void load(){
27+
28+
api.registerAllEvents();
29+
api.addTS3Listeners(new TS3Listener() {
30+
31+
32+
@Override
33+
public void onClientJoin(ClientJoinEvent e) {
34+
35+
Client client = api.getClientByUId(e.getUniqueClientIdentifier());
36+
WordFilterManager.check(client.getNickname());
37+
if(WordFilterManager.check(client.getNickname())) {
38+
api.kickClientFromServer("Blacklisted name! Please change it!", client);
39+
}
40+
// check for 'bad-names'
41+
42+
}
43+
44+
@Override
45+
public void onTextMessage(TextMessageEvent e) {
46+
// ...
47+
}
48+
49+
@Override
50+
public void onServerEdit(ServerEditedEvent e) {
51+
// ...
52+
}
53+
54+
@Override
55+
public void onClientMoved(ClientMovedEvent e) {
56+
// ...
57+
}
58+
59+
@Override
60+
public void onClientLeave(ClientLeaveEvent e) {
61+
// ...
62+
}
63+
64+
@Override
65+
public void onChannelEdit(ChannelEditedEvent e) {
66+
// ...
67+
}
68+
69+
@Override
70+
public void onChannelDescriptionChanged(ChannelDescriptionEditedEvent e) {
71+
// ...
72+
}
73+
74+
@Override
75+
public void onChannelCreate(ChannelCreateEvent e) {
76+
// ...
77+
}
78+
79+
@Override
80+
public void onChannelDeleted(ChannelDeletedEvent e) {
81+
// ...
82+
}
83+
84+
@Override
85+
public void onChannelMoved(ChannelMovedEvent e) {
86+
// ...
87+
}
88+
89+
@Override
90+
public void onChannelPasswordChanged(ChannelPasswordChangedEvent e) {
91+
// ...
92+
}
93+
94+
@Override
95+
public void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e) {
96+
// ...
97+
}
98+
});
99+
}
100+
}
101+
102+
103+
104+
/**
105+
*
106+
* @author Joel Rzepka - crackscout.de
107+
*
108+
* @date 09.06.2023 - 23:32:48
109+
*
110+
*/

src/de/crackscout/Events/StackedEvents.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import de.crackscout.AdminBot.Main;
2020
import de.crackscout.Managers.AuthManager;
21-
import de.crackscout.Managers.Debug;
2221

2322
public class StackedEvents {
2423

@@ -40,10 +39,8 @@ public void onClientJoin(ClientJoinEvent e) {
4039
+ "\n!stay - Ignore AFK"
4140
+ "\n!kickme - Self kick"
4241
+ "\n!clear - Clear the Array cache"
43-
+ "\n!ping - Ping");
44-
}else {
45-
46-
Debug.err("no auth");
42+
+ "\n!ping - Ping"
43+
+ "\n!stats - Show debuging informations");
4744
}
4845
}
4946

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package de.crackscout.Managers;
2+
3+
import java.io.IOException;
4+
import java.nio.file.Files;
5+
import java.nio.file.Paths;
6+
import java.util.List;
7+
8+
import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
9+
10+
public class WordFilterManager {
11+
12+
// Initialize variables
13+
public static Client sender;
14+
public static Client target;
15+
public static String file = "blacklisted_words.app";
16+
public static Boolean enabled = Boolean.parseBoolean(ConfigManager.loadProp("enabled", file));
17+
18+
public static List<String> words = readWords();
19+
20+
public static void createDefaults() {
21+
if(!ConfigManager.checkForDefault(file)) {
22+
ConfigManager.saveProp("enabled", "true", file);
23+
}
24+
}
25+
26+
27+
// BIG TODO HERE !!! I may use regex patterns and matchers;
28+
29+
public static boolean check(String toBeChecked) {
30+
if(enabled){
31+
// for (String word : words) {
32+
// Debug.info("1");
33+
// if(toBeChecked.contains(word) ) {
34+
// Debug.info("2");
35+
// return true;
36+
// }
37+
// }
38+
for (int i = 0; i < words.size(); i++) {
39+
System.out.println("USER: " + toBeChecked + " LIST: " + words.get(i));
40+
if(toBeChecked.matches(words.get(i)) ) {
41+
System.out.println("matched");
42+
return true;
43+
}
44+
}
45+
}
46+
return false;
47+
}
48+
49+
public static List<String> readWords() { // words are phrased line by line
50+
try {
51+
List<String> allLines = Files.readAllLines(Paths.get("AdminBot/"+file));
52+
allLines.remove(0);
53+
allLines.remove(0);
54+
return allLines;
55+
56+
} catch (IOException e) {
57+
e.printStackTrace();
58+
return null;
59+
}
60+
}
61+
62+
63+
}
64+
65+
66+
/**
67+
*
68+
* @author Joel Rzepka - crackscout.de
69+
*
70+
* @date 10.06.2023 - 00:09:19
71+
*
72+
*/

0 commit comments

Comments
 (0)