mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-12 10:00:19 +00:00
add simple text dsl for textsources
This commit is contained in:
@@ -8,12 +8,22 @@ import io.ktor.client.HttpClient
|
||||
import io.ktor.client.HttpClientConfig
|
||||
import io.ktor.client.engine.*
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [urlsKeeper]
|
||||
*/
|
||||
fun telegramBot(
|
||||
urlsKeeper: TelegramAPIUrlsKeeper
|
||||
): TelegramBot = KtorRequestsExecutor(
|
||||
urlsKeeper,
|
||||
HttpClient()
|
||||
)
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [urlsKeeper] and already prepared [client]
|
||||
*/
|
||||
fun telegramBot(
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient = HttpClient()
|
||||
client: HttpClient
|
||||
): TelegramBot = KtorRequestsExecutor(
|
||||
urlsKeeper,
|
||||
client
|
||||
@@ -60,6 +70,15 @@ inline fun telegramBot(
|
||||
HttpClient(clientConfig)
|
||||
)
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client]
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun telegramBot(
|
||||
token: String,
|
||||
apiUrl: String = telegramBotAPIDefaultUrl
|
||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl))
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client]
|
||||
*/
|
||||
@@ -67,7 +86,7 @@ inline fun telegramBot(
|
||||
inline fun telegramBot(
|
||||
token: String,
|
||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||
client: HttpClient = HttpClient()
|
||||
client: HttpClient
|
||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl), client)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -106,7 +125,7 @@ inline fun telegramBot(
|
||||
inline fun telegramBot(
|
||||
token: String,
|
||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit
|
||||
) = telegramBot(
|
||||
TelegramAPIUrlsKeeper(token, apiUrl),
|
||||
clientConfig
|
||||
|
||||
Reference in New Issue
Block a user