mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
commit
cf5cee3e53
2
.github/workflows/kdocs.yml
vendored
2
.github/workflows/kdocs.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 17
|
||||
- name: Build
|
||||
run: ./gradlew dokkaHtmlMultiModule
|
||||
- name: Publish KDocs
|
||||
|
4
.github/workflows/packages_publishing.yml
vendored
4
.github/workflows/packages_publishing.yml
vendored
@ -7,9 +7,9 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 17
|
||||
- name: Setup LibCurl
|
||||
run: sudo apt install -y libcurl4-openssl-dev
|
||||
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev
|
||||
- name: Rewrite version
|
||||
run: |
|
||||
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
|
||||
|
18
CHANGELOG.md
18
CHANGELOG.md
@ -1,5 +1,23 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 9.3.0
|
||||
|
||||
This release become possible thanks to [Anton Lakotka](https://youtrack.jetbrains.com/users/anton.lakotka)
|
||||
|
||||
**THIS RELEASE CONTAINS UPDATES UP TO RELEASE CANDIDATES VERSIONS**
|
||||
|
||||
**UPDATE MAY HAVE BREAKING CHANGES**
|
||||
|
||||
**SINCE THIS UPDATE IT WILL BE REQUIRED TO USE JDK 17+ FOR DEVELOPMENT**
|
||||
|
||||
* `Version`:
|
||||
* `Kotlin`: `1.8.22` -> `1.9.20`
|
||||
* `Serialization`: `1.5.1` -> `1.6.0`
|
||||
* `KorLibs`: `4.0.3` -> `4.0.10`
|
||||
* `UUID`: `0.7.1` -> `0.8.1`
|
||||
* `Ktor`: `2.3.4` -> `2.3.5`
|
||||
* `MicroUtils`: `0.19.9` -> `0.20.12`
|
||||
|
||||
## 9.2.4
|
||||
|
||||
* `Utils`:
|
||||
|
@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=9.2.4
|
||||
library_version=9.3.0
|
||||
|
@ -1,22 +1,22 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "1.8.22"
|
||||
kotlin-serialization = "1.5.1"
|
||||
kotlin = "1.9.20"
|
||||
kotlin-serialization = "1.6.0"
|
||||
kotlin-coroutines = "1.7.3"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "4.0.3"
|
||||
uuid = "0.7.1"
|
||||
ktor = "2.3.4"
|
||||
korlibs = "4.0.10"
|
||||
uuid = "0.8.1"
|
||||
ktor = "2.3.5"
|
||||
|
||||
ksp = "1.8.22-1.0.11"
|
||||
ksp = "1.9.20-1.0.14"
|
||||
kotlin-poet = "1.14.2"
|
||||
|
||||
microutils = "0.19.9"
|
||||
microutils = "0.20.12"
|
||||
|
||||
github-release-plugin = "2.4.1"
|
||||
dokka = "1.8.20"
|
||||
dokka = "1.9.10"
|
||||
|
||||
[libraries]
|
||||
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
|
@ -5,7 +5,7 @@ kotlin {
|
||||
jvm {
|
||||
compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
jvmTarget = "17"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15,6 +15,7 @@ kotlin {
|
||||
}
|
||||
linuxX64()
|
||||
mingwX64()
|
||||
linuxArm64()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
@ -40,10 +41,18 @@ kotlin {
|
||||
implementation libs.kotlin.test.junit
|
||||
}
|
||||
}
|
||||
all {
|
||||
languageSettings {
|
||||
optIn('dev.inmo.tgbotapi.utils.RiskFeature')
|
||||
optIn('dev.inmo.tgbotapi.utils.PreviewFeature')
|
||||
optIn('dev.inmo.micro_utils.common.Warning')
|
||||
optIn('dev.inmo.micro_utils.common.PreviewFeature')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
task javadocsJar(type: Jar) {
|
||||
archiveClassifier.convention("javadoc")
|
||||
archiveClassifier.set("javadoc")
|
||||
archiveClassifier = 'javadoc'
|
||||
}
|
||||
|
||||
publishing {
|
||||
@ -97,4 +96,10 @@ if (project.hasProperty("signing.gnupg.keyName")) {
|
||||
dependsOn(it)
|
||||
}
|
||||
}
|
||||
|
||||
// Workaround to make android sign operations depend on signing tasks
|
||||
project.getTasks().withType(AbstractPublishToMaven.class).configureEach {
|
||||
def signingTasks = project.getTasks().withType(Sign.class)
|
||||
mustRunAfter(signingTasks)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
actual var defaultCoroutineScopeProvider: () -> CoroutineScope = { CoroutineScope(Dispatchers.Default) }
|
@ -55,6 +55,12 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
linuxArm64Main {
|
||||
dependencies {
|
||||
api libs.ktor.client.cio
|
||||
}
|
||||
}
|
||||
|
||||
mingwX64Main {
|
||||
dependencies {
|
||||
api libs.ktor.client.winhttp
|
||||
|
@ -14,7 +14,18 @@ import kotlinx.serialization.json.Json
|
||||
* * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor]
|
||||
* * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor]
|
||||
*/
|
||||
expect class KtorRequestsExecutor (
|
||||
expect class KtorRequestsExecutor internal constructor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient,
|
||||
callsFactories: List<KtorCallFactory>,
|
||||
excludeDefaultFactories: Boolean,
|
||||
requestsLimiter: RequestLimiter,
|
||||
jsonFormatter: Json,
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||
diff: Unit // just a diff property to know where constructor and where calling function with defaults
|
||||
) : BaseRequestsExecutor
|
||||
|
||||
fun KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient = HttpClient(),
|
||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||
@ -22,4 +33,13 @@ expect class KtorRequestsExecutor (
|
||||
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||
jsonFormatter: Json = nonstrictJsonFormat,
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||
) : BaseRequestsExecutor
|
||||
) = KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper = telegramAPIUrlsKeeper,
|
||||
client = client,
|
||||
callsFactories = callsFactories,
|
||||
excludeDefaultFactories = excludeDefaultFactories,
|
||||
requestsLimiter = requestsLimiter,
|
||||
jsonFormatter = jsonFormatter,
|
||||
pipelineStepsHolder = pipelineStepsHolder,
|
||||
diff = kotlin.Unit
|
||||
)
|
||||
|
@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||
@ -19,14 +20,15 @@ import io.ktor.client.plugins.*
|
||||
import io.ktor.client.statement.*
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
class DefaultKtorRequestsExecutor(
|
||||
class DefaultKtorRequestsExecutor internal constructor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient = HttpClient(),
|
||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||
excludeDefaultFactories: Boolean = false,
|
||||
private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||
private val jsonFormatter: Json = nonstrictJsonFormat,
|
||||
private val pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||
client: HttpClient,
|
||||
callsFactories: List<KtorCallFactory>,
|
||||
excludeDefaultFactories: Boolean,
|
||||
private val requestsLimiter: RequestLimiter,
|
||||
private val jsonFormatter: Json,
|
||||
private val pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||
diff: Unit
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||
if (!excludeDefaultFactories) {
|
||||
|
@ -4,9 +4,12 @@ import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import io.ktor.client.*
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
@ -55,7 +58,8 @@ class MultipleClientKtorRequestsExecutor (
|
||||
excludeDefaultFactories,
|
||||
requestsLimiter,
|
||||
jsonFormatter,
|
||||
pipelineStepsHolder
|
||||
pipelineStepsHolder,
|
||||
Unit
|
||||
)
|
||||
}.toSet()
|
||||
private val freeClients = MutableStateFlow<Set<DefaultKtorRequestsExecutor>>(requestExecutors)
|
||||
@ -68,14 +72,15 @@ class MultipleClientKtorRequestsExecutor (
|
||||
}
|
||||
}
|
||||
|
||||
constructor(
|
||||
internal constructor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient,
|
||||
callsFactories: List<KtorCallFactory>,
|
||||
excludeDefaultFactories: Boolean,
|
||||
requestsLimiter: RequestLimiter,
|
||||
jsonFormatter: Json,
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||
diff: Unit
|
||||
) : this(
|
||||
telegramAPIUrlsKeeper,
|
||||
callsFactories,
|
||||
|
@ -7,7 +7,9 @@ import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@ -25,7 +27,7 @@ data class StoryContent(
|
||||
replyToMessageId: MessageId?,
|
||||
allowSendingWithoutReply: Boolean?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<out Message> {
|
||||
): Request<PossiblyForwardedMessage> {
|
||||
return ForwardMessage(
|
||||
chat.id,
|
||||
toChatId = chatId,
|
||||
|
1
tgbotapi.core/src/linuxArm64Main/kotlin/PackageInfo.kt
Normal file
1
tgbotapi.core/src/linuxArm64Main/kotlin/PackageInfo.kt
Normal file
@ -0,0 +1 @@
|
||||
package dev.inmo.tgbotapi
|
@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor
|
||||
|
||||
import dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor
|
||||
|
||||
actual typealias KtorRequestsExecutor = MultipleClientKtorRequestsExecutor
|
@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.base
|
||||
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
|
||||
/**
|
||||
* This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native
|
||||
* platforms and MingwX64 should return [client]
|
||||
*
|
||||
* On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl
|
||||
*
|
||||
* @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64
|
||||
*/
|
||||
internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = (client.engineConfig as? CIOEngineConfig) ?.let {
|
||||
lateinit var config: HttpClientConfig<out CIOEngineConfig>
|
||||
client.config {
|
||||
config = this as HttpClientConfig<out CIOEngineConfig>
|
||||
}.close()
|
||||
HttpClient(CIO) {
|
||||
this.plusAssign(config)
|
||||
}
|
||||
} ?: throw IllegalArgumentException("On LinuxX64 TelegramBotAPI currently support only Curl Ktor HttpClient engine")
|
@ -0,0 +1,9 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
import dev.inmo.micro_utils.ktor.common.input
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
|
||||
actual fun MPPFile.asMultipartFile(): MultipartFile = MultipartFile(this.name) {
|
||||
input()
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.readRemaining
|
||||
|
||||
actual suspend fun ByteReadChannel.asInput(): Input = readRemaining()
|
@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
//actual typealias MimeType = MimeType
|
||||
|
||||
@OptIn(RiskFeature::class)
|
||||
@Serializable(MimeTypeSerializer::class)
|
||||
actual data class MimeType(
|
||||
actual val raw: String
|
||||
)
|
||||
internal actual fun createMimeType(raw: String): MimeType = MimeType(raw)
|
@ -4,6 +4,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
//actual typealias MimeType = MimeType
|
||||
|
||||
@OptIn(RiskFeature::class)
|
||||
@Serializable(MimeTypeSerializer::class)
|
||||
actual data class MimeType(
|
||||
actual val raw: String
|
||||
|
@ -24,6 +24,7 @@ class TelegramBotAPISymbolProcessor(
|
||||
private val outputFile: String = "Output",
|
||||
private val outputFolder: String? = null
|
||||
) : SymbolProcessor {
|
||||
@OptIn(RiskFeature::class)
|
||||
private val classCastsIncludedClassName = ClassCastsIncluded::class.asClassName()
|
||||
@OptIn(KspExperimental::class, RiskFeature::class)
|
||||
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||
|
@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
|
||||
import dev.inmo.tgbotapi.types.update.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
|
||||
|
||||
/**
|
||||
@ -22,6 +23,7 @@ fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier? {
|
||||
* Will convert incoming list of [Update]s to list with [Update]s, which include [dev.inmo.tgbotapi.types.message.abstracts.ContentMessage]s
|
||||
* with [dev.inmo.tgbotapi.types.message.content.MediaGroupContent]
|
||||
*/
|
||||
@OptIn(RiskFeature::class)
|
||||
fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
|
||||
val resultUpdates = mutableListOf<Update>()
|
||||
val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<Pair<BaseSentMessageUpdate, PossiblySentViaBotCommonMessage<MediaGroupPartContent>>>>()
|
||||
|
Loading…
Reference in New Issue
Block a user