mirror of
https://github.com/amalthea-mc/spigot-tg-bridge.git
synced 2024-11-08 19:51:04 +00:00
Fix text handling issue
This commit is contained in:
parent
7c45aa2140
commit
655ab4b002
@ -7,7 +7,6 @@ import org.bukkit.event.player.AsyncPlayerChatEvent
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent
|
||||
import org.bukkit.event.player.PlayerJoinEvent
|
||||
import org.bukkit.event.player.PlayerQuitEvent
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
class EventHandler(
|
||||
private val tgBot: TgBot,
|
||||
@ -18,14 +17,9 @@ class EventHandler(
|
||||
fun onPlayerChat(event: AsyncPlayerChatEvent) {
|
||||
if (!config.logFromMCtoTG) return
|
||||
event.run {
|
||||
measureTimeMillis {
|
||||
tgBot.sendMessageToTelegram(
|
||||
message, player.displayName
|
||||
)
|
||||
}
|
||||
.also {
|
||||
println("Time: $it")
|
||||
}
|
||||
tgBot.sendMessageToTelegram(
|
||||
message, player.displayName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,10 +100,11 @@ class TgBot(
|
||||
private suspend fun handleUpdate() {
|
||||
val update = updateChan.receive()
|
||||
update.message?.text?.let {
|
||||
println("Text: $it")
|
||||
commandRegex.matchEntire(it)?.groupValues?.let {
|
||||
commandMap[it[1]]?.let { it(update) } ?: onTextHandler(update)
|
||||
commandMap[it[1]]?.let { it(update) }
|
||||
}
|
||||
} ?: run {
|
||||
onTextHandler(update)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,6 @@ package org.kraftwerk28.spigot_tg_bridge
|
||||
|
||||
import com.vdurmont.emoji.EmojiParser
|
||||
|
||||
// fun Bot.skipUpdates(lastUpdateID: Long = 0) {
|
||||
// val newUpdates = getUpdates(lastUpdateID)
|
||||
|
||||
// if (newUpdates.isNotEmpty()) {
|
||||
// val lastUpd = newUpdates.last()
|
||||
// if (lastUpd !is Update) return
|
||||
// return skipUpdates(lastUpd.updateId + 1)
|
||||
// }
|
||||
// }
|
||||
|
||||
fun String.escapeHtml() = this
|
||||
.replace("&", "&")
|
||||
.replace(">", ">")
|
||||
|
Loading…
Reference in New Issue
Block a user