This library provides a Kotlin Coroutines
client for the Telegram Database Library
(TDLib).
repositories {
mavenCentral()
}
dependencies {
implementation("dev.g000sha256:tdl-coroutines:1.4.0")
}
Caution
The TDLib
frequently includes breaking changes in its minor versions.
To reduce breaking changes when updating the TDL Coroutines
library,
use named arguments for constructors and methods, as new parameters may be added in future releases.
val client = TdlClient.create()
The TdlClient
provides 159 update flows, as well as one that includes all updates.
coroutineScope.launch {
client.authorizationStateUpdates.collect { updateAuthorizationState ->
val authorizationState = updateAuthorizationState.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
}
}
}
The TdlClient
provides 877 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
}
}
}