mirror of
https://github.com/amalthea-mc/spigot-tg-bridge.git
synced 2024-11-09 20:21:04 +00:00
feature: release 0.0.14
Changelog: - fixed delayed plugin start (issue with long polling)
This commit is contained in:
parent
4a00808ab5
commit
5e52b18805
@ -8,6 +8,7 @@
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="$PROJECT_DIR$/../../../../Program Files/Gradle/gradle-6.5.1" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
@ -32,6 +32,7 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
|
||||
val slashRegex = "^/+".toRegex()
|
||||
val commands = config.commands
|
||||
|
||||
skipUpdates()
|
||||
bot = bot {
|
||||
token = config.botToken
|
||||
logLevel = HttpLoggingInterceptor.Level.NONE
|
||||
@ -45,14 +46,13 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
|
||||
}.filterKeys { it != null }
|
||||
|
||||
dispatch {
|
||||
cmdBinding.forEach { text, handler ->
|
||||
command(text!!, handler as HandleUpdate)
|
||||
cmdBinding.forEach { (text, handler) ->
|
||||
command(text!!.replace(slashRegex, ""), handler)
|
||||
}
|
||||
text(null, ::onText)
|
||||
}
|
||||
}
|
||||
bot.setMyCommands(getBotCommands())
|
||||
bot.skipUpdates()
|
||||
|
||||
config.webhookConfig?.let { _ ->
|
||||
plugin.logger.info("Running in webhook mode.")
|
||||
@ -173,10 +173,21 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
|
||||
return cmdList.zip(descList).map { BotCommand(it.first, it.second) }
|
||||
}
|
||||
|
||||
private fun skipUpdates() {
|
||||
bot {
|
||||
token = config.botToken
|
||||
timeout = 0
|
||||
}.skipUpdates()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun escapeHTML(s: String) =
|
||||
s.replace("&", "&").replace(">", ">").replace("<", "<")
|
||||
fun escapeHTML(s: String) = s
|
||||
.replace("&", "&")
|
||||
.replace(">", ">")
|
||||
.replace("<", "<")
|
||||
|
||||
fun escapeColorCodes(s: String) = s.replace("\u00A7.".toRegex(), "")
|
||||
|
||||
fun fullEscape(s: String) = escapeColorCodes(escapeHTML(s))
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
name: SpigotTGBridge
|
||||
version: 0.0.13
|
||||
version: 0.0.14
|
||||
api-version: '1.15'
|
||||
main: org.kraftwerk28.spigot_tg_bridge.Plugin
|
||||
description: Telegram <-> Minecraft communication plugin for Spigot.
|
||||
|
Loading…
Reference in New Issue
Block a user