mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 23:29:33 +00:00
add fileLinkUrlMapper to all callers of TelegramAPIUrlsKeeper constructors
This commit is contained in:
@@ -377,9 +377,9 @@ public final class dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutorFactoriesKt {
|
||||
public static final fun createTelegramBotDefaultKtorCallRequestsFactories (Ldev/inmo/kslog/common/KSLog;)Ljava/util/List;
|
||||
public static synthetic fun createTelegramBotDefaultKtorCallRequestsFactories$default (Ldev/inmo/kslog/common/KSLog;ILjava/lang/Object;)Ljava/util/List;
|
||||
public static final fun telegramBot (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Lkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/bot/RequestsExecutor;
|
||||
public static final fun telegramBot (Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/bot/RequestsExecutor;
|
||||
public static final fun telegramBot (Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/bot/RequestsExecutor;
|
||||
public static synthetic fun telegramBot$default (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/inmo/tgbotapi/bot/RequestsExecutor;
|
||||
public static synthetic fun telegramBot$default (Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/inmo/tgbotapi/bot/RequestsExecutor;
|
||||
public static synthetic fun telegramBot$default (Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/inmo/tgbotapi/bot/RequestsExecutor;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutorKt {
|
||||
@@ -30832,10 +30832,12 @@ public final class dev/inmo/tgbotapi/utils/StringFileExtensionKt {
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper$Companion;
|
||||
public static final field DEFAULT_URL Ljava/lang/String;
|
||||
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)V
|
||||
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Ljava/lang/String;ZLjava/lang/String;)V
|
||||
public synthetic fun <init> (Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Ljava/lang/String;ZLjava/lang/String;Lkotlin/jvm/functions/Function2;)V
|
||||
public synthetic fun <init> (Ljava/lang/String;ZLjava/lang/String;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun checkWebAppData (Ljava/lang/String;Ljava/lang/String;)Z
|
||||
public final fun createFileLinkUrl (Ljava/lang/String;)Ljava/lang/String;
|
||||
public final fun getCommonAPIUrl ()Ljava/lang/String;
|
||||
@@ -30844,6 +30846,9 @@ public final class dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper {
|
||||
public final fun getWebAppDataSecretKeyHash ()Lkorlibs/crypto/Hash;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper$Companion {
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeperKt {
|
||||
public static final field telegramBotAPIDefaultUrl Ljava/lang/String;
|
||||
}
|
||||
|
@@ -53,11 +53,19 @@ inline fun telegramBot(
|
||||
/**
|
||||
* Shortcut for [telegramBot]
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun telegramBot(
|
||||
fun telegramBot(
|
||||
token: String,
|
||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||
testServer: Boolean = false,
|
||||
fileLinkUrlMapper: TelegramAPIUrlsKeeper.(String) -> String = { "${fileBaseUrl}/$it" },
|
||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {}
|
||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), builder)
|
||||
): TelegramBot = telegramBot(
|
||||
telegramAPIUrlsKeeper = TelegramAPIUrlsKeeper(
|
||||
token = token,
|
||||
testServer = testServer,
|
||||
hostUrl = apiUrl,
|
||||
fileLinkUrlMapper = fileLinkUrlMapper
|
||||
),
|
||||
builder = builder
|
||||
)
|
||||
|
||||
|
@@ -4,8 +4,6 @@ import korlibs.crypto.*
|
||||
import io.ktor.http.decodeURLQueryComponent
|
||||
import io.ktor.utils.io.core.toByteArray
|
||||
|
||||
const val telegramBotAPIDefaultUrl = "https://api.telegram.org"
|
||||
|
||||
private inline val String.withoutLastSlash: String
|
||||
get() {
|
||||
var correctedUrl = this
|
||||
@@ -33,10 +31,16 @@ class TelegramAPIUrlsKeeper(
|
||||
val commonAPIUrl: String
|
||||
val fileBaseUrl: String
|
||||
|
||||
constructor(token: String, testServer: Boolean, hostUrl: String = telegramBotAPIDefaultUrl) : this(
|
||||
token,
|
||||
hostUrl,
|
||||
"/test".takeIf { testServer } ?: ""
|
||||
constructor(
|
||||
token: String,
|
||||
testServer: Boolean,
|
||||
hostUrl: String = telegramBotAPIDefaultUrl,
|
||||
fileLinkUrlMapper: TelegramAPIUrlsKeeper.(String) -> String = { "${fileBaseUrl}/$it" }
|
||||
) : this(
|
||||
token = token,
|
||||
hostUrl = hostUrl,
|
||||
urlsSuffixes = "/test".takeIf { testServer } ?: "",
|
||||
fileLinkUrlMapper = fileLinkUrlMapper
|
||||
)
|
||||
|
||||
init {
|
||||
@@ -61,4 +65,10 @@ class TelegramAPIUrlsKeeper(
|
||||
|
||||
return HMAC.hmacSHA256(webAppDataSecretKeyHash.bytes, preparedData.toByteArray()).hexLower == hash.lowercase()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_URL = "https://api.telegram.org"
|
||||
}
|
||||
}
|
||||
|
||||
const val telegramBotAPIDefaultUrl = TelegramAPIUrlsKeeper.DEFAULT_URL
|
||||
|
Reference in New Issue
Block a user