maybe fix intellij fuckery, make the bot send the username of the user we're adding (thanks tud), make the logingenerator fucking flush the outputstreams (fuck you tud)
This commit is contained in:
parent
e9a34b9f98
commit
2c21b4ba95
3 changed files with 19 additions and 18 deletions
|
@ -18,8 +18,10 @@ dependencies {
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
|
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
|
||||||
|
|
||||||
|
implementation(fileTree(dir: "libs", include: "*.jar"))
|
||||||
|
|
||||||
jarLibs("net.dv8tion:JDA:5.0.0-beta.24")
|
jarLibs("net.dv8tion:JDA:5.0.0-beta.24")
|
||||||
jarLibs(files('libs/TuddyLIB.jar'))
|
jarLibs(fileTree(dir: "libs", include: "*.jar"))
|
||||||
|
|
||||||
implementation configurations.jarLibs
|
implementation configurations.jarLibs
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.baseband.bot;
|
package com.baseband.bot;
|
||||||
|
|
||||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
|
||||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
|
||||||
|
|
||||||
import de.tudbut.io.TypedInputStream;
|
import de.tudbut.io.TypedInputStream;
|
||||||
import de.tudbut.io.TypedOutputStream;
|
import de.tudbut.io.TypedOutputStream;
|
||||||
import de.tudbut.net.ws.Client;
|
import de.tudbut.net.ws.Client;
|
||||||
|
@ -24,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
import static de.tudbut.net.http.HTTPContentType.TCN;
|
|
||||||
import static net.dv8tion.jda.api.interactions.commands.OptionType.STRING;
|
import static net.dv8tion.jda.api.interactions.commands.OptionType.STRING;
|
||||||
import static net.dv8tion.jda.api.interactions.commands.OptionType.USER;
|
import static net.dv8tion.jda.api.interactions.commands.OptionType.USER;
|
||||||
|
|
||||||
|
@ -83,7 +79,7 @@ public class Main extends ListenerAdapter {
|
||||||
TypedInputStream tis;
|
TypedInputStream tis;
|
||||||
TypedOutputStream tos;
|
TypedOutputStream tos;
|
||||||
try {
|
try {
|
||||||
Socket connection = new Socket("baseband.lol", 40001);
|
Socket connection = new Socket("127.0.0.1", 40001);
|
||||||
tis = new TypedInputStream(connection.getInputStream());
|
tis = new TypedInputStream(connection.getInputStream());
|
||||||
tos = new TypedOutputStream(connection.getOutputStream());
|
tos = new TypedOutputStream(connection.getOutputStream());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -106,22 +102,23 @@ public class Main extends ListenerAdapter {
|
||||||
|
|
||||||
switch (tis.readInt()) {
|
switch (tis.readInt()) {
|
||||||
case 201: {
|
case 201: {
|
||||||
event.reply("Reset the HWID of **`" + user.getName() + "`**.").setEphemeral(true).queue();
|
event.getChannel().sendMessage("Reset the HWID of **`" + user.getName() + "`**.").queue();
|
||||||
|
event.reply("`Success.`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 403: {
|
case 403: {
|
||||||
event.reply("Incorrect Admin Password.").setEphemeral(true).queue();
|
event.reply("`Incorrect Admin Password.`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 400: {
|
case 400: {
|
||||||
event.reply("Error! I sent malformed data somehow.").setEphemeral(true).queue();
|
event.reply("`Error! I sent malformed data somehow.`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 404: {
|
case 404: {
|
||||||
event.reply("User Not Found, Do they have BaseBand?").setEphemeral(true).queue();
|
event.reply("`User Not Found, Do they have BaseBand?`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +142,7 @@ public class Main extends ListenerAdapter {
|
||||||
try {
|
try {
|
||||||
TCN tcn = new TCN();
|
TCN tcn = new TCN();
|
||||||
tcn.set("action", "add");
|
tcn.set("action", "add");
|
||||||
|
tcn.set("username", username); //wow yes don't give the username to the server-side great job
|
||||||
tcn.set("authorisation", Hasher.sha512hex(password));
|
tcn.set("authorisation", Hasher.sha512hex(password));
|
||||||
tcn.set("discord-id", user.getIdLong());
|
tcn.set("discord-id", user.getIdLong());
|
||||||
tos.writeString(tcn.toString());
|
tos.writeString(tcn.toString());
|
||||||
|
@ -156,22 +154,22 @@ public class Main extends ListenerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 403: {
|
case 403: {
|
||||||
event.reply("Incorrect Admin Password.").setEphemeral(true).queue();
|
event.reply("`Incorrect Admin Password.`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 409: {
|
case 409: {
|
||||||
event.reply("User already exists!").setEphemeral(true).queue();
|
event.reply("`User already exists!`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 400: {
|
case 400: {
|
||||||
event.reply("Error! I sent malformed data somehow.").setEphemeral(true).queue();
|
event.reply("`Error! I sent malformed data somehow.`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
event.reply("Error! I am out of sync with the server.").setEphemeral(true).queue();
|
event.reply("`Error! I am out of sync with the server.`").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,8 +229,4 @@ public class Main extends ListenerAdapter {
|
||||||
event.reply("I can't handle that command right now :(").setEphemeral(true).queue();
|
event.reply("I can't handle that command right now :(").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void say(SlashCommandInteractionEvent event, String content) {
|
|
||||||
event.reply(content).queue(); // This requires no permissions!
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -26,5 +26,10 @@ public class LoginGenerator {
|
||||||
writer.println(k.encryptString(username));
|
writer.println(k.encryptString(username));
|
||||||
writer.println(k.encryptString(password));
|
writer.println(k.encryptString(password));
|
||||||
writer.println(k.encryptString("GENERATED USING " + LoginGenerator.class.getName() + "!!"));
|
writer.println(k.encryptString("GENERATED USING " + LoginGenerator.class.getName() + "!!"));
|
||||||
|
//dumb as rocks
|
||||||
|
writer.flush();
|
||||||
|
fos.flush();
|
||||||
|
writer.close();
|
||||||
|
fos.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue