8000 GitHub - uakihir0/kbsky at v0.1.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

uakihir0/kbsky

Repository files navigation

日本語

kbsky

Maven metadata URL

badge badge badge

This library is a Bluesky/ATProtocol client library compatible with Kotlin Multiplatform. It depends on khttpclient and internally uses Ktor Client. Therefore, this library is available on platforms supported by Kotlin Multiplatform and Ktor Client. The behavior on each platform depends on khttpclient.

Usage

The following is how to use Gradle with Kotlin on supported platforms. For Apple platform, please refer to kbsky-cocoapods. Also, please check the test code as well.

repositories {
    mavenCentral()
+   maven { url = uri("https://repo.repsy.io/mvn/uakihir0/public") }
}

dependencies {
+   implementation("work.socialhub.kbsky:core:0.0.1-SNAPSHOT")
+   implementation("work.socialhub.kbsky:stream:0.0.1-SNAPSHOT")
}

CreateSession

val response = BlueskyFactory
    .instance(BSKY_SOCIAL.uri)
    .server()
    .createSession(
        ServerCreateSessionRequest().also {
            it.identifier = HANDLE
            it.password = PASSWORD
        }
    )

println(response.data.accessJwt)

SendFeed

BlueskyFactory
    .instance(BSKY_SOCIAL.uri)
    .feed()
    .post(
        FeedPostRequest(accessJwt).also {
            it.text = "Hello World!"
        }
    )

PLC Directory

val response = PLCDirectoryFactory
    .instance()
    .DIDDetails(did)

println(checkNotNull(response.data.alsoKnownAs)[0])

SubscribeRepos (stream)

val stream = ATProtocolStreamFactory
    .instance(
        apiUri = BSKY_SOCIAL.uri,
        streamUri = BSKY_NETWORK.uri
    )
    .sync()
    .subscribeRepos(
        SyncSubscribeReposRequest().also {
            it.filter = listOf(
                "app.bsky.feed.post"
            )
        }
    )

stream.eventCallback(
    object : EventCallback {
        override fun onEvent(
            cid: String?,
            uri: String?,
            record: RecordUnion
        ) {
            print(record)
        }
    })

License

MIT License

Author

Akihiro Urushihara

About

Kotlin multiplatform Bluesky/ATProtocol library.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 8

Languages

0