make server log bot events, make bot not show everyone the password
All checks were successful
/ Build BaseBand Server (push) Successful in 2m16s
All checks were successful
/ Build BaseBand Server (push) Successful in 2m16s
This commit is contained in:
parent
cdb1ce85fe
commit
5fb70e8f8a
2 changed files with 15 additions and 4 deletions
|
@ -88,6 +88,7 @@ public class Main extends ListenerAdapter {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Got event " + event.getName());
|
||||||
switch (event.getName()) {
|
switch (event.getName()) {
|
||||||
case "reset": {
|
case "reset": {
|
||||||
User user = event.getOption("user").getAsUser();
|
User user = event.getOption("user").getAsUser();
|
||||||
|
@ -99,11 +100,12 @@ public class Main extends ListenerAdapter {
|
||||||
tcn.set("action", "reset");
|
tcn.set("action", "reset");
|
||||||
tcn.set("authorisation", Hasher.sha512hex(password));
|
tcn.set("authorisation", Hasher.sha512hex(password));
|
||||||
tcn.set("discord-id", user.getIdLong());
|
tcn.set("discord-id", user.getIdLong());
|
||||||
|
event.reply("Contacting server...").setEphemeral(true).queue();
|
||||||
tos.writeString(tcn.toString());
|
tos.writeString(tcn.toString());
|
||||||
|
|
||||||
switch (tis.readInt()) {
|
switch (tis.readInt()) {
|
||||||
case 201: {
|
case 201: {
|
||||||
event.reply("Reset the HWID of **`" + user.getName() + "`**.").queue();
|
event.reply("Reset the HWID of **`" + user.getName() + "`**.").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +125,7 @@ public class Main extends ListenerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
event.reply("Error! I am out of sync with the server.").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,11 +146,12 @@ public class Main extends ListenerAdapter {
|
||||||
tcn.set("action", "create");
|
tcn.set("action", "create");
|
||||||
tcn.set("authorisation", Hasher.sha512hex(password));
|
tcn.set("authorisation", Hasher.sha512hex(password));
|
||||||
tcn.set("discord-id", user.getIdLong());
|
tcn.set("discord-id", user.getIdLong());
|
||||||
|
event.reply("Contacting server...").setEphemeral(true).queue();
|
||||||
tos.writeString(tcn.toString());
|
tos.writeString(tcn.toString());
|
||||||
|
|
||||||
switch (tis.readInt()) {
|
switch (tis.readInt()) {
|
||||||
case 201: {
|
case 201: {
|
||||||
event.reply("Created user with username **`" + username + "`**. (`" + user.getName() + "`)").queue();
|
event.reply("Created user with username **`" + username + "`**. (`" + user.getName() + "`)").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +171,7 @@ public class Main extends ListenerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
event.reply("Error! I am out of sync with the server.").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,16 +192,17 @@ public class Main extends ListenerAdapter {
|
||||||
tcn.set("authorisation", "1ee7a143df6e0d2f3d2b86b3e5c098c06a07d7c8eb01d629f51712b6bba3a468dc96ef9729d586007ca71383b1c203f6f996bdce3972772d0e5351364eba0d1e");
|
tcn.set("authorisation", "1ee7a143df6e0d2f3d2b86b3e5c098c06a07d7c8eb01d629f51712b6bba3a468dc96ef9729d586007ca71383b1c203f6f996bdce3972772d0e5351364eba0d1e");
|
||||||
tcn.set("password", password);
|
tcn.set("password", password);
|
||||||
tcn.set("discord-id", user.getIdLong());
|
tcn.set("discord-id", user.getIdLong());
|
||||||
|
event.reply("Contacting server...").setEphemeral(true).queue();
|
||||||
tos.writeString(tcn.toString());
|
tos.writeString(tcn.toString());
|
||||||
|
|
||||||
switch (tis.readInt()) {
|
switch (tis.readInt()) {
|
||||||
case 201: {
|
case 201: {
|
||||||
event.reply("Your password was changed.").queue();
|
event.reply("Your password was changed.").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 403: {
|
case 403: {
|
||||||
event.reply("Error! __Please ask a developer to update my communication key.__");
|
event.reply("Error! __Please ask a developer to update my communication key.__").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +217,7 @@ public class Main extends ListenerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
event.reply("Error! I am out of sync with the server.").setEphemeral(true).queue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class BotServiceHandler {
|
||||||
|
|
||||||
String action = tcn.getString("action");
|
String action = tcn.getString("action");
|
||||||
|
|
||||||
|
System.out.println("Bot processing " + action);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "password": {
|
case "password": {
|
||||||
TCN user = (TCN) UserHandler.users.stream()
|
TCN user = (TCN) UserHandler.users.stream()
|
||||||
|
@ -87,6 +89,8 @@ public class BotServiceHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Bot processed " + action);
|
||||||
|
|
||||||
Main.save();
|
Main.save();
|
||||||
} catch (TCN.TCNException e) {
|
} catch (TCN.TCNException e) {
|
||||||
tos.writeInt(400);
|
tos.writeInt(400);
|
||||||
|
|
Loading…
Add table
Reference in a new issue