mirror of https://github.com/kami-blue/client
Some updates to the AntiSpam module. (#826)
This commit is contained in:
parent
510f974371
commit
224b83c6e4
|
@ -54,6 +54,7 @@ class AntiSpam : Module() {
|
||||||
private val webLinks = register(Settings.booleanBuilder("Web Links").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
private val webLinks = register(Settings.booleanBuilder("Web Links").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||||
private val filterOwn = register(Settings.booleanBuilder("Filter Own").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
private val filterOwn = register(Settings.booleanBuilder("Filter Own").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||||
private val filterDMs = register(Settings.booleanBuilder("Filter DMs").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
private val filterDMs = register(Settings.booleanBuilder("Filter DMs").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||||
|
private val filterServer = register(Settings.booleanBuilder("Filter server").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||||
private val showBlocked = register(Settings.enumBuilder(ShowBlocked::class.java).withName("Show Blocked").withValue(ShowBlocked.LOG_FILE).withVisibility { p.value == Page.TWO }.build())
|
private val showBlocked = register(Settings.enumBuilder(ShowBlocked::class.java).withName("Show Blocked").withValue(ShowBlocked.LOG_FILE).withVisibility { p.value == Page.TWO }.build())
|
||||||
private var messageHistory: ConcurrentHashMap<String, Long>? = null
|
private var messageHistory: ConcurrentHashMap<String, Long>? = null
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ class AntiSpam : Module() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum class ShowBlocked {
|
private enum class ShowBlocked {
|
||||||
NONE, LOG_FILE, CHAT
|
NONE, LOG_FILE, CHAT, BOTH
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -91,7 +92,7 @@ class AntiSpam : Module() {
|
||||||
private fun isSpam(message: String): Boolean {
|
private fun isSpam(message: String): Boolean {
|
||||||
/* Quick bandaid fix for mc.player being null when the module is being registered, so don't register it with the map */
|
/* Quick bandaid fix for mc.player being null when the module is being registered, so don't register it with the map */
|
||||||
val ownMessage = "^<" + mc.player.name + "> "
|
val ownMessage = "^<" + mc.player.name + "> "
|
||||||
return if (!filterOwn.value && isOwn(ownMessage, message) || MessageDetectionHelper.isDirect(filterDMs.value, message) || MessageDetectionHelper.isDirectOther(filterDMs.value, message)) {
|
return if (!filterOwn.value && isOwn(ownMessage, message) || MessageDetectionHelper.isDirect(!filterDMs.value, message) || MessageDetectionHelper.isDirectOther(!filterDMs.value, message) || MessageDetectionHelper.isQueue(!filterServer.value, message) || MessageDetectionHelper.isRestart(!filterServer.value, message)) {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
detectSpam(removeUsername(message))
|
detectSpam(removeUsername(message))
|
||||||
|
@ -118,7 +119,8 @@ class AntiSpam : Module() {
|
||||||
messageHistory!![message] = System.currentTimeMillis()
|
messageHistory!![message] = System.currentTimeMillis()
|
||||||
|
|
||||||
if (isDuplicate) {
|
if (isDuplicate) {
|
||||||
if (showBlocked.value == ShowBlocked.CHAT) MessageSendHelper.sendChatMessage(chatName + "Duplicate: " + message) else if (showBlocked.value == ShowBlocked.LOG_FILE) KamiMod.log.info(chatName + "Duplicate: " + message)
|
if (showBlocked.value == ShowBlocked.CHAT || showBlocked.value == ShowBlocked.BOTH) MessageSendHelper.sendChatMessage(chatName + "Duplicate: " + message)
|
||||||
|
if (showBlocked.value == ShowBlocked.LOG_FILE || showBlocked.value == ShowBlocked.BOTH) KamiMod.log.info(chatName + "Duplicate: " + message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -144,7 +146,6 @@ class AntiSpam : Module() {
|
||||||
put(greenText, FilterPatterns.GREEN_TEXT)
|
put(greenText, FilterPatterns.GREEN_TEXT)
|
||||||
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING)
|
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING)
|
||||||
put(specialCharEnding, FilterPatterns.SPECIAL_ENDING)
|
put(specialCharEnding, FilterPatterns.SPECIAL_ENDING)
|
||||||
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING)
|
|
||||||
put(ownsMeAndAll, FilterPatterns.OWNS_ME_AND_ALL)
|
put(ownsMeAndAll, FilterPatterns.OWNS_ME_AND_ALL)
|
||||||
put(iJustThanksTo, FilterPatterns.I_JUST_THANKS_TO)
|
put(iJustThanksTo, FilterPatterns.I_JUST_THANKS_TO)
|
||||||
put(numberSuffix, FilterPatterns.NUMBER_SUFFIX)
|
put(numberSuffix, FilterPatterns.NUMBER_SUFFIX)
|
||||||
|
@ -298,6 +299,7 @@ class AntiSpam : Module() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendResult(name: String, message: String) {
|
private fun sendResult(name: String, message: String) {
|
||||||
if (showBlocked.value == ShowBlocked.CHAT) MessageSendHelper.sendChatMessage("$chatName$name: $message") else if (showBlocked.value == ShowBlocked.LOG_FILE) KamiMod.log.info("$chatName$name: $message")
|
if (showBlocked.value == ShowBlocked.CHAT || showBlocked.value == ShowBlocked.BOTH) MessageSendHelper.sendChatMessage("$chatName$name: $message")
|
||||||
|
if (showBlocked.value == ShowBlocked.LOG_FILE || showBlocked.value == ShowBlocked.BOTH) KamiMod.log.info("$chatName$name: $message")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue