Skip to content

Commit 5e52b18

Browse files
committed
feature: release 0.0.14
Changelog: - fixed delayed plugin start (issue with long polling)
1 parent 4a00808 commit 5e52b18

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.idea/gradle.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/TgBot.kt

+16-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
3232
val slashRegex = "^/+".toRegex()
3333
val commands = config.commands
3434

35+
skipUpdates()
3536
bot = bot {
3637
token = config.botToken
3738
logLevel = HttpLoggingInterceptor.Level.NONE
@@ -45,14 +46,13 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
4546
}.filterKeys { it != null }
4647

4748
dispatch {
48-
cmdBinding.forEach { text, handler ->
49-
command(text!!, handler as HandleUpdate)
49+
cmdBinding.forEach { (text, handler) ->
50+
command(text!!.replace(slashRegex, ""), handler)
5051
}
5152
text(null, ::onText)
5253
}
5354
}
5455
bot.setMyCommands(getBotCommands())
55-
bot.skipUpdates()
5656

5757
config.webhookConfig?.let { _ ->
5858
plugin.logger.info("Running in webhook mode.")
@@ -173,10 +173,21 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
173173
return cmdList.zip(descList).map { BotCommand(it.first, it.second) }
174174
}
175175

176+
private fun skipUpdates() {
177+
bot {
178+
token = config.botToken
179+
timeout = 0
180+
}.skipUpdates()
181+
}
182+
176183
companion object {
177-
fun escapeHTML(s: String) =
178-
s.replace("&", "&amp;").replace(">", "&gt;").replace("<", "&lt;")
184+
fun escapeHTML(s: String) = s
185+
.replace("&", "&amp;")
186+
.replace(">", "&gt;")
187+
.replace("<", "&lt;")
188+
179189
fun escapeColorCodes(s: String) = s.replace("\u00A7.".toRegex(), "")
190+
180191
fun fullEscape(s: String) = escapeColorCodes(escapeHTML(s))
181192
}
182193
}

src/main/resources/plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: SpigotTGBridge
2-
version: 0.0.13
2+
version: 0.0.14
33
api-version: '1.15'
44
main: org.kraftwerk28.spigot_tg_bridge.Plugin
55
description: Telegram <-> Minecraft communication plugin for Spigot.

0 commit comments

Comments
 (0)