
Offers a Coroutines client for the Telegram Database Library, enabling asynchronous operations with generated Data Transfer Objects. Supports 159 update flows and 867 request methods.
TDL Coroutines is a Kotlin Multiplatform library that provides a coroutine-based client for the Telegram Database Library (TDLib). It simplifies sending requests and handling updates, making TDLib integration more straightforward and idiomatic for Kotlin Multiplatform projects.
| Mobile |
|
| Desktop |
|
repositories {
mavenCentral()
}Replace X.X.X with the version from the Maven Central badge.
dependencies {
implementation("dev.g000sha256:tdl-coroutines:X.X.X")
}[!CAUTION] Upstream TDLib may include breaking API changes even in patch releases. Since TDL Coroutines wraps TDLib, these changes propagate to this library as well. To minimize the impact, use named arguments when calling generated constructors and request methods, because parameters may be added, renamed, or removed in future releases.
val client = TdlClient.create()[!IMPORTANT] Start collecting the update flows you need before sending the first request.
TdlClient provides 184 update flows and the allUpdates flow, which combines all update events.
coroutineScope.launch {
client.authorizationStateUpdates.collect { update ->
val authorizationState = update.authorizationState
// TODO
}
}coroutineScope.launch {
client.allUpdates.collect { update ->
when (update) {
is UpdateAuthorizationState -> {
val authorizationState = update.authorizationState
// TODO
}
is UpdateOption -> {
val name = update.name
val value = update.value
// TODO
}
// TODO
}
}
}TdlClient provides 1010 request methods.
coroutineScope.launch {
val result = client.getAuthorizationState()
when (result) {
is TdlResult.Failure -> {
val code = result.code
val message = result.message
// TODO
}
is TdlResult.Success -> {
val authorizationState = result.result
// TODO
}
}
}[!TIP] You can use the
.toResult()extension to convertTdlResult<T>to the standard KotlinResult<T>type.
TDL Coroutines is a Kotlin Multiplatform library that provides a coroutine-based client for the Telegram Database Library (TDLib). It simplifies sending requests and handling updates, making TDLib integration more straightforward and idiomatic for Kotlin Multiplatform projects.
| Mobile |
|
| Desktop |
|
repositories {
mavenCentral()
}Replace X.X.X with the version from the Maven Central badge.
dependencies {
implementation("dev.g000sha256:tdl-coroutines:X.X.X")
}[!CAUTION] Upstream TDLib may include breaking API changes even in patch releases. Since TDL Coroutines wraps TDLib, these changes propagate to this library as well. To minimize the impact, use named arguments when calling generated constructors and request methods, because parameters may be added, renamed, or removed in future releases.
val client = TdlClient.create()[!IMPORTANT] Start collecting the update flows you need before sending the first request.
TdlClient provides 184 update flows and the allUpdates flow, which combines all update events.
coroutineScope.launch {
client.authorizationStateUpdates.collect { update ->
val authorizationState = update.authorizationState
// TODO
}
}coroutineScope.launch {
client.allUpdates.collect { update ->
when (update) {
is UpdateAuthorizationState -> {
val authorizationState = update.authorizationState
// TODO
}
is UpdateOption -> {
val name = update.name
val value = update.value
// TODO
}
// TODO
}
}
}TdlClient provides 1010 request methods.
coroutineScope.launch {
val result = client.getAuthorizationState()
when (result) {
is TdlResult.Failure -> {
val code = result.code
val message = result.message
// TODO
}
is TdlResult.Success -> {
val authorizationState = result.result
// TODO
}
}
}[!TIP] You can use the
.toResult()extension to convertTdlResult<T>to the standard KotlinResult<T>type.