feature: release 0.0.14

Changelog:
  - fixed delayed plugin start (issue with long polling)
This commit is contained in:
kraftwerk28 2020-07-25 14:37:07 +03:00
parent 4a00808ab5
commit 5e52b18805
3 changed files with 18 additions and 6 deletions

View File

@ -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$" />

View File

@ -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("&", "&amp;").replace(">", "&gt;").replace("<", "&lt;")
fun escapeHTML(s: String) = s
.replace("&", "&amp;")
.replace(">", "&gt;")
.replace("<", "&lt;")
fun escapeColorCodes(s: String) = s.replace("\u00A7.".toRegex(), "")
fun fullEscape(s: String) = escapeColorCodes(escapeHTML(s))
}
}

View File

@ -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.