@@ -8,7 +8,6 @@ import com.github.kotlintelegrambot.entities.ParseMode
8
8
import com.github.kotlintelegrambot.entities.Update
9
9
import com.github.kotlintelegrambot.entities.User
10
10
import okhttp3.logging.HttpLoggingInterceptor
11
- import kotlin.reflect.KProperty0
12
11
import org.kraftwerk28.spigot_tg_bridge.Constants as C
13
12
14
13
fun Bot.skipUpdates (lastUpdateID : Long = 0) {
@@ -106,7 +105,7 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
106
105
val playerList = plugin.server.onlinePlayers
107
106
val playerStr = plugin.server
108
107
.onlinePlayers
109
- .mapIndexed { i, s -> " ${i + 1 } . ${s.displayName} " }
108
+ .mapIndexed { i, s -> " ${i + 1 } . ${fullEscape( s.displayName) } " }
110
109
.joinToString(" \n " )
111
110
val text =
112
111
if (playerList.isNotEmpty()) " ${config.onlineString} :\n $playerStr "
@@ -159,7 +158,9 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
159
158
}
160
159
161
160
private fun messageFromMinecraft (username : String , text : String ): String =
162
- " <i>${escape(username)} </i>: $text "
161
+ config.minecraftMessageFormat
162
+ .replace(" %username%" , fullEscape(username))
163
+ .replace(" %message%" , escapeHTML(text))
163
164
164
165
private fun rawUserMention (user : User ): String =
165
166
(if (user.firstName.length < 2 ) null else user.firstName)
@@ -176,6 +177,6 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
176
177
fun escapeHTML (s : String ) =
177
178
s.replace(" &" , " &" ).replace(" >" , " >" ).replace(" <" , " <" )
178
179
fun escapeColorCodes (s : String ) = s.replace(" \u00A7 ." .toRegex(), " " )
179
- fun escape (s : String ) = escapeColorCodes(escapeHTML(s))
180
+ fun fullEscape (s : String ) = escapeColorCodes(escapeHTML(s))
180
181
}
181
182
}
0 commit comments