From 74c480b07edadf287d54d1e6b64ca8d7f74905ff Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 17 Nov 2020 16:18:58 +0600 Subject: [PATCH] one new telegramBot function --- .../dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt | 10 ++++++++++ .../dev/inmo/tgbotapi/extensions/api/BotExtensions.kt | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt index cdaf835e84..db18339ec3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/KtorRequestsExecutor.kt @@ -31,6 +31,16 @@ inline fun telegramBot( crossinline builder: KtorRequestsExecutorBuilder.() -> Unit = {} ): TelegramBot = KtorRequestsExecutorBuilder(telegramAPIUrlsKeeper).apply(builder).build() +/** + * Shortcut for [telegramBot] + */ +@Suppress("NOTHING_TO_INLINE") +inline fun telegramBot( + token: String, + apiUrl: String = telegramBotAPIDefaultUrl, + crossinline builder: KtorRequestsExecutorBuilder.() -> Unit = {} +): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl), builder) + class KtorRequestsExecutor( telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, client: HttpClient = HttpClient(), diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt index 606018acbb..18c1c2bcfb 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.extensions.api +import dev.inmo.tgbotapi.bot.Ktor.KtorRequestsExecutorBuilder import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl @@ -71,11 +72,12 @@ inline fun telegramBot( /** * Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client] */ +@Deprecated("Replaced in core", ReplaceWith("telegramBot", "dev.inmo.tgbotapi.bot.Ktor.telegramBot")) @Suppress("NOTHING_TO_INLINE") inline fun telegramBot( token: String, apiUrl: String = telegramBotAPIDefaultUrl -): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl)) +): TelegramBot = dev.inmo.tgbotapi.bot.Ktor.telegramBot(token, apiUrl) /** * Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client]