@@ -32,6 +32,7 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
32
32
val slashRegex = " ^/+" .toRegex()
33
33
val commands = config.commands
34
34
35
+ skipUpdates()
35
36
bot = bot {
36
37
token = config.botToken
37
38
logLevel = HttpLoggingInterceptor .Level .NONE
@@ -45,14 +46,13 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
45
46
}.filterKeys { it != null }
46
47
47
48
dispatch {
48
- cmdBinding.forEach { text, handler ->
49
- command(text!! , handler as HandleUpdate )
49
+ cmdBinding.forEach { ( text, handler) ->
50
+ command(text!! .replace(slashRegex, " " ), handler )
50
51
}
51
52
text(null , ::onText)
52
53
}
53
54
}
54
55
bot.setMyCommands(getBotCommands())
55
- bot.skipUpdates()
56
56
57
57
config.webhookConfig?.let { _ ->
58
58
plugin.logger.info(" Running in webhook mode." )
@@ -173,10 +173,21 @@ class TgBot(private val plugin: Plugin, private val config: Configuration) {
173
173
return cmdList.zip(descList).map { BotCommand (it.first, it.second) }
174
174
}
175
175
176
+ private fun skipUpdates () {
177
+ bot {
178
+ token = config.botToken
179
+ timeout = 0
180
+ }.skipUpdates()
181
+ }
182
+
176
183
companion object {
177
- fun escapeHTML (s : String ) =
178
- s.replace(" &" , " &" ).replace(" >" , " >" ).replace(" <" , " <" )
184
+ fun escapeHTML (s : String ) = s
185
+ .replace(" &" , " &" )
186
+ .replace(" >" , " >" )
187
+ .replace(" <" , " <" )
188
+
179
189
fun escapeColorCodes (s : String ) = s.replace(" \u00A7 ." .toRegex(), " " )
190
+
180
191
fun fullEscape (s : String ) = escapeColorCodes(escapeHTML(s))
181
192
}
182
193
}
0 commit comments