mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-20 13:15:43 +00:00
artifacts names has been changed
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.utils.StorageFile
|
||||
import java.io.File
|
||||
|
||||
fun File.toInputFile() = if (exists()) {
|
||||
MultipartFile(
|
||||
StorageFile(this)
|
||||
)
|
||||
} else {
|
||||
error("Specified file $absolutePath does not exists")
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun CommonUser.javaLocale(): Locale? = languageCode ?.let {
|
||||
Locale.forLanguageTag(it)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.payments
|
||||
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
|
||||
import java.util.*
|
||||
|
||||
fun Currencied.javaCurrency(): Currency = Currency.getInstance(currency)
|
||||
@@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.updateshandlers.webhook
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
import java.io.FileInputStream
|
||||
import java.security.KeyStore
|
||||
|
||||
@Serializable
|
||||
data class WebhookPrivateKeyConfig(
|
||||
private val keyStorePath: String,
|
||||
private val keyStorePassword: String,
|
||||
val aliasName: String,
|
||||
private val aliasPassword: String
|
||||
) {
|
||||
@Transient
|
||||
val keyStore = KeyStore.getInstance("JKS").apply {
|
||||
load(FileInputStream(keyStorePath), keyStorePassword())
|
||||
}
|
||||
|
||||
fun keyStorePassword(): CharArray = keyStorePassword.toCharArray()
|
||||
|
||||
fun aliasPassword(): CharArray = aliasPassword.toCharArray()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable(MimeTypeSerializer::class)
|
||||
actual class MimeType(
|
||||
actual val raw: String
|
||||
) : javax.activation.MimeType(raw)
|
||||
|
||||
actual fun createMimeType(raw: String): MimeType = MimeType(raw)
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import io.ktor.utils.io.streams.asInput
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
fun StorageFile(
|
||||
file: File
|
||||
) = StorageFile(
|
||||
StorageFileInfo(
|
||||
Files.probeContentType(file.toPath()),
|
||||
file.name
|
||||
)
|
||||
) {
|
||||
file.inputStream().asInput()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.utils.extensions
|
||||
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
fun <T> T.asReference() = WeakReference(this)
|
||||
Reference in New Issue
Block a user