Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Aug 9, 2024
1 parent a170ed6 commit daa97e3
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 76 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies {
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("ch.qos.logback:logback-classic:1.4.12")
implementation("com.github.promeg:tinypinyin:2.0.3")
implementation("com.huaban:jieba-analysis:+")
implementation("com.github.promeg:tinypinyin-lexicons-java-cncity:2.0.3")
implementation("org.json:json:20231013")
implementation("org.apache.httpcomponents:httpclient:4.5.14")
Expand Down
12 changes: 0 additions & 12 deletions src/main/kotlin/ltd/guimc/lgzbot/command/LGZBotCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
package ltd.guimc.lgzbot.command

import ltd.guimc.lgzbot.PluginMain
import ltd.guimc.lgzbot.counter.VLManager
import ltd.guimc.lgzbot.files.ModuleStateConfig
import ltd.guimc.lgzbot.listener.message.MessageFilter
import ltd.guimc.lgzbot.utils.LL4JUtils
import ltd.guimc.lgzbot.utils.MessageUtils.getPlainText
import ltd.guimc.lgzbot.utils.OverflowUtils
import ltd.guimc.lgzbot.word.WordUtils
import net.mamoe.mirai.Bot
import net.mamoe.mirai.console.command.*
import net.mamoe.mirai.contact.Member
Expand All @@ -37,16 +35,6 @@ object LGZBotCommand : CompositeCommand(
sendMessage("Pong!")
}

@SubCommand("word")
@Description("词频统计")
suspend fun CommandSender.word(user: Member,time: String) {
try {
sendMessage("他的词频信息:\n${WordUtils.hashMapToString(WordUtils.sortAndTrim(VLManager.getCounter(user).wordFrequency,Integer.parseInt(time)))}")
} catch (e: Exception) {
sendMessage("Oops! Something went wrong! ${e.message}")
}
}

@SubCommand("mute")
@Description("把某人的嘴巴用胶布粘上")
suspend fun CommandSender.mute(user: Member, time: String, reason: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import ltd.guimc.lgzbot.utils.MessageUtils.getPlainText
import ltd.guimc.lgzbot.utils.RegexUtils
import ltd.guimc.lgzbot.utils.TextUtils.findSimilarity
import ltd.guimc.lgzbot.utils.TextUtils.removeNonVisible
import ltd.guimc.lgzbot.word.WordUtils
import net.mamoe.mirai.console.permission.Permission
import net.mamoe.mirai.console.permission.PermissionService.Companion.hasPermission
import net.mamoe.mirai.console.permission.PermitteeId.Companion.permitteeId
Expand Down Expand Up @@ -308,13 +307,6 @@ object MessageFilter {
}

val counter = VLManager.getCounter(e.sender)
WordUtils.filter(e.message.content).forEach {
if (counter.wordFrequency[it] != null) {
counter.wordFrequency[it] = counter.wordFrequency[it]!! + 1
} else {
counter.wordFrequency[it] = 0
}
}

if ((e.sender.permitteeId.hasPermission(PluginMain.blocked) && !e.sender.permitteeId.hasPermission(bypassMute)) || (e.group.permitteeId.hasPermission(
PluginMain.blocked
Expand Down
33 changes: 0 additions & 33 deletions src/main/kotlin/ltd/guimc/lgzbot/word/WordUtils.kt

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/serious.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,6 @@ engadget中文网
民国
民进党
民运
民主
民主潮
摩门教
纳粹
南华早报
Expand Down
21 changes: 1 addition & 20 deletions src/test/java/Test.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
import ltd.guimc.lgzbot.utils.LL4JUtils;

import java.nio.charset.Charset;
import java.util.Arrays;

public class Test {
public static void main(String[] args) {
LL4JUtils.INSTANCE.init();
System.out.println(Charset.defaultCharset());
System.out.println(Arrays.toString(LL4JUtils.INSTANCE.predictAllResult("")));
System.out.println(LL4JUtils.INSTANCE.getModel().predict(LL4JUtils.INSTANCE.getTokenizer().tokenize(0, " Oyster 新内步" +
"学生党の首选" +
"[+]吻订沙路,让您所向披靡" +
"[+]反击退,让您不再惧怕掉进虚空" +
"[+]叨抱,让沙路的抱力更上一层楼" +
"[+]搭路,吻订不吞方块" +
"[+]瞬移,远程偷家让别人 die 都不知道怎么 die 的" +
"[+]视觉美丽的同时让您 fps++" +
"[+]完美结局总动 GG,装 b 更加彻底" +
"[+]万能的管理不会不耐烦" +
"[+]我们承诺永不跑路" +
"内步 15r buy➕1632596365").values));
public static void main(String[] args) throws InterruptedException {
}
}

0 comments on commit daa97e3

Please sign in to comment.