An convenient wrapper for kotlogram
// bot auth
client.botAuth(...)
// user auth
client.auth(...)
val alex = client.getByUsername("y9san9") as User
val crinny = client.getByUsername("crinny") as User
client.updates {
command("start") {
it.reply("Welcome!")
}
message {
filter {
it.from.id in listOf(alex.id, crinny.id)
}
println("${it.from.fullname}: ${it.message}")
}
}
- wrap all api with convenient functions and models
- upgrade api layer to latest
repositories {
maven { url "https://jitpack.io" } // Connecting jitpack to import github repos
}
dependencies {
implementation 'com.github.y9san9:kotlogram2:-SNAPSHOT'
implementation 'com.github.y9san9:kotlogram:-SNAPSHOT' // should be implemented to use unwrapped api
}
Add this 2 functions to top of your build.gradle.kts
/**
* Import github repo; first add [jitpack] to repos
* @param repo username/repo; e.g. y9san9/kotlogram2
*/
fun DependencyHandlerScope.github(repo: String, tag: String = "-SNAPSHOT") = implementation(
repo.split("/").let { (username, repo) ->
"com.github.${username}:${repo}:${tag}"
}
)
/**
* Jitpack maven
*/
fun RepositoryHandler.jitpack() = maven("https://jitpack.io")
then use pretty easy implementation code
repositories {
jitpack()
}
dependencies {
github("y9san9/kotlogram") // should be implemented to use unwrapped api
github("y9san9/kotlogram2")
}
The project is in beta, so public api can be changed any time. For stable work use releases instead of -SNAPSHOT
See: wiki, examples