mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
buildBot
This commit is contained in:
parent
7c43d3aaa5
commit
a193ef5fd5
@ -7,6 +7,8 @@
|
||||
* `Klock`: `2.0.0` -> `2.0.1`
|
||||
* `Ktor`: `1.4.2` -> `1.4.3`
|
||||
* `MicroUtils`: `0.4.6` -> `0.4.9`
|
||||
* `API Extensions`:
|
||||
* New function `buildBot`
|
||||
|
||||
## 0.30.9
|
||||
|
||||
|
@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.HttpClientConfig
|
||||
import io.ktor.client.engine.*
|
||||
@ -36,10 +37,25 @@ data class BotBuilder internal constructor(
|
||||
* @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and
|
||||
* [block]
|
||||
*/
|
||||
fun buildBot(
|
||||
token: String,
|
||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||
block: BotBuilder.() -> Unit
|
||||
) = telegramBot(
|
||||
TelegramAPIUrlsKeeper(token, apiUrl),
|
||||
BotBuilder().apply(block).createHttpClient()
|
||||
)
|
||||
|
||||
/**
|
||||
* @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and
|
||||
* [block]
|
||||
*/
|
||||
@Deprecated("Renamed", ReplaceWith("buildBot", "dev.inmo.tgbotapi.extensions.api.buildBot"))
|
||||
fun telegramBot(
|
||||
token: String,
|
||||
block: BotBuilder.() -> Unit
|
||||
): TelegramBot = telegramBot(
|
||||
TelegramAPIUrlsKeeper(token),
|
||||
BotBuilder().apply(block).createHttpClient()
|
||||
): TelegramBot = buildBot(
|
||||
token,
|
||||
telegramBotAPIDefaultUrl,
|
||||
block
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user