[fix] AutoReply / AntiAFK replying to self

Closes #1560

Signed-off-by: Dominika <sokolov.dominika@gmail.com>
This commit is contained in:
Dominika 2020-11-13 21:54:03 -05:00
parent 621117e458
commit 72f45d5698
No known key found for this signature in database
GPG Key ID: B4A5A6DCA70F861F
3 changed files with 5 additions and 3 deletions

View File

@ -20,7 +20,7 @@ object AutoReply : Module() {
init {
listener<PacketEvent.Receive> {
if (it.packet !is SPacketChat || !MessageDetectionHelper.isDirect(true, it.packet.getChatComponent().unformattedText)) return@listener
if (it.packet !is SPacketChat || !MessageDetectionHelper.isDirectReceived(true, it.packet.getChatComponent().unformattedText)) return@listener
if (customMessage.value) {
sendServerMessage("/r " + message.value)
} else {

View File

@ -67,7 +67,7 @@ object AntiAFK : Module() {
listener<PacketEvent.Receive> {
if (!autoReply.value || it.packet !is SPacketChat) return@listener
if (MessageDetectionHelper.isDirect(true, it.packet.getChatComponent().unformattedText)) {
if (MessageDetectionHelper.isDirectReceived(true, it.packet.getChatComponent().unformattedText)) {
sendServerMessage("/r I am currently AFK and using KAMI Blue!")
}
}

View File

@ -30,7 +30,9 @@ object MessageDetectionHelper {
return if (message == "KamiBlueMessageType2") "Disconnected from $server" else ""
}
fun isDirect(direct: Boolean, message: String) = message.detect(direct, Regexes.DIRECT, Regexes.DIRECT_ALT_1, Regexes.DIRECT_ALT_2, Regexes.DIRECT_SENT)
fun isDirectReceived(direct: Boolean, message: String) = message.detect(direct, Regexes.DIRECT, Regexes.DIRECT_ALT_1, Regexes.DIRECT_ALT_2)
fun isDirect(direct: Boolean, message: String) = message.detect(direct, Regexes.DIRECT_SENT) || isDirectReceived(direct, message)
fun getDirectUsername(message: String): String? {
if (!isDirect(true, message)) return null