Giter Club home page Giter Club logo

kook-kt's Introduction

kook-kt


一个 KOOK Kotlin SDK

快速开始

引入依赖

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.github.hank9999</groupId>
        <artifactId>kook-kt</artifactId>
        <version>0.0.1-fix1</version>
    </dependency>
</dependencies>

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.hank9999:kook-kt:0.0.1-fix1'
}

使用

fun main(args: Array<String>) {
    val bot = Bot(Config(token = "xxxx"))
    // 注册监听事件
    bot.registerClass(M())
    bot.registerMessageFunc { msg, cs -> message2(msg, cs) }
    bot.registerMessageFunc { msg, cs -> message3(msg, cs) }
}

class M {
    @Bot.OnMessage
    suspend fun message(msg: Message) {
        logger.info(msg.toString())
    }

    @Bot.OnEvent
    suspend fun event(event: Event) {
        logger.info(event.toString())
    }

    @Bot.OnFilter(FilterTypes.START_WITH, "/1234")
    suspend fun filter(msg: Message) {
        logger.info(msg.toString())
    }

    @Bot.OnCommand("test")
    suspend fun command(msg: Message) {
        logger.info(msg.toString())
    }
}
fun message2(msg: Message, cs: CoroutineScope) {
    println(msg)
}

fun message3(msg: Message, cs: CoroutineScope) {
    cs.launch {
        delay(500)
        logger.info(msg.toString())
    }
}

LICENSE

本仓库采用 MIT 开源协议
CallAwait.ktCallStackRecorder.kt 来自于 gildor/kotlin-coroutines-okhttp 使用 Apache License 2.0 授权

kook-kt's People

Contributors

hank9999 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.