fixes and improvements !!!

This commit is contained in:
ChomeNS
2023-07-03 16:33:14 +07:00
parent 98ca810275
commit be31cb7a0d
3 changed files with 14 additions and 11 deletions

View File

@@ -1,5 +1,7 @@
package land.chipmunk.chayapak.chomens_bot.plugins;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import io.socket.client.IO;
import io.socket.client.Socket;
import land.chipmunk.chayapak.chomens_bot.Bot;
@@ -24,6 +26,8 @@ public class EvalPlugin {
public final List<EvalFunction> functions = new ArrayList<>();
private final Gson gson = new Gson();
public EvalPlugin (Bot bot) {
functions.add(new CoreFunction(bot));
functions.add(new ChatFunction(bot));
@@ -37,7 +41,14 @@ public class EvalPlugin {
socket.on(Socket.EVENT_CONNECT, (args) -> {
connected = true;
socket.emit("setFunctions", "chat", "core");
final JsonArray array = new JsonArray();
for (EvalFunction function : functions) array.add(function.name);
socket.emit(
"setFunctions",
gson.toJson(array)
);
});
socket.on(Socket.EVENT_DISCONNECT, (args) -> connected = false);
socket.on(Socket.EVENT_CONNECT_ERROR, (args) -> connected = false);

View File

@@ -28,7 +28,7 @@ public class HashingPlugin {
final long time = System.currentTimeMillis() / 5_000;
// mabe this will optimize it?
if (time == lastTime) return;
if (time <= lastTime) return;
lastTime = time;
final String normalHashKey = bot.config.keys.normalKey;
@@ -40,7 +40,7 @@ public class HashingPlugin {
.toString()
.substring(0, 16);
final String ownerHashValue = (System.currentTimeMillis() / 5_000) + ownerHashKey;
final String ownerHashValue = time + ownerHashKey;
ownerHash = Hashing.sha256()
.hashString(ownerHashValue, StandardCharsets.UTF_8)
.toString()