fixes and improvements !!!

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

View file

@ -3,14 +3,6 @@
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Gradle Imported" enabled="true">
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.26/lombok-1.18.26.jar" />
</processorPath>
<module name="chomens_bot.test" />
<module name="chomens_bot.main" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="17" />
</component>

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()