1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-12-08 15:25:52 +00:00

Compare commits

..

8 Commits

6 changed files with 31 additions and 10 deletions

View File

@@ -42,6 +42,17 @@
* `HttpClient#loadFile`
* `PathedFile#download`
### 0.28.1
* Common:
* Versions updates:
* `Kotlin`: `1.4.0` -> `1.4.10`
* `UUID`: `0.2.1` -> `0.2.2`
* `TelegramBotAPI-core`:
* `ExceptionHandler` has changed its incoming type: `Exception` -> `Throwable`
* `handleSafely` has changed its signature
* `executeUnsafe` has changed its signature
## 0.27.0
* `Common`:

View File

@@ -4,7 +4,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.supervisorScope
typealias ExceptionHandler<T> = suspend (Exception) -> T
typealias ExceptionHandler<T> = suspend (Throwable) -> T
/**
* It will run [block] inside of [supervisorScope] to avoid problems with catching of exceptions
*
@@ -17,7 +17,7 @@ suspend inline fun <T> handleSafely(
): T {
return try {
supervisorScope(block)
} catch (e: Exception) {
} catch (e: Throwable) {
onException(e)
}
}

View File

@@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
import kotlinx.serialization.json.Json
import kotlin.test.Test
import kotlin.test.assertEquals
private val nonstrictJsonFormat = Json {
isLenient = true
@@ -22,9 +23,18 @@ class SimpleInputFilesTest {
PhotoSize("example_file_id".toInputFile(), "example_unique_file_id", 100, 100, 100)
)
)
nonstrictJsonFormat.encodeToString(
val inputMedia = photoContent.toMediaGroupMemberInputMedia()
assertEquals(photoContent.media.fileId, inputMedia.file)
val encoded = nonstrictJsonFormat.encodeToString(
MediaGroupMemberInputMediaSerializer,
photoContent.toMediaGroupMemberInputMedia()
inputMedia
)
assertEquals(
inputMedia,
nonstrictJsonFormat.decodeFromString(
MediaGroupMemberInputMediaSerializer,
encoded
)
)
}
}

View File

@@ -24,10 +24,10 @@ suspend fun <T: Any> RequestsExecutor.executeUnsafe(
request: Request<T>,
retries: Int = 0,
retriesDelay: Long = 1000L,
onAllFailed: (suspend (exceptions: Array<Exception>) -> Unit)? = null
onAllFailed: (suspend (exceptions: Array<Throwable>) -> Unit)? = null
): T? {
var leftRetries = retries
val exceptions = onAllFailed ?.let { mutableListOf<Exception>() }
val exceptions = onAllFailed ?.let { mutableListOf<Throwable>() }
do {
return handleSafely(
{

View File

@@ -5,16 +5,16 @@ kotlin.js.generate.externals=true
kotlin.incremental=true
kotlin.incremental.js=true
kotlin_version=1.4.0
kotlin_version=1.4.10
kotlin_coroutines_version=1.3.9
kotlin_serialisation_runtime_version=1.0.0-RC
klock_version=1.12.0
uuid_version=0.2.1
uuid_version=0.2.2
ktor_version=1.4.0
javax_activation_version=1.1.1
library_group=com.github.insanusmokrassar
library_version=0.28.0
library_version=0.28.1
gradle_bintray_plugin_version=1.8.5

View File

@@ -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-6.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip