Skip to content

Commit

Permalink
one new telegramBot function
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Nov 17, 2020
1 parent 657e9aa commit 74c480b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 74c480b

Please sign in to comment.