Skip to content
This repository has been archived by the owner on Apr 4, 2021. It is now read-only.

y9san9/kotlogram2

Repository files navigation

Welcome to kotlogram2 👋

An convenient wrapper for kotlogram

codebeat badge Licence Issues PRs welcome Views

HoC

👀 Example

// 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}")
    }
}

🚩 TODO

  • wrap all api with convenient functions and models
  • upgrade api layer to latest

🚀 Installation (Gradle)

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
}

🔥 Pro way (Kotlin Gradle DSL)

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