跳转到主要内容

YumeBot

基于 NapCatQQ 的 Kotlin QQ 机器人开发框架,提供简洁优雅的 API 和强大的插件系统。

快速示例

package plugins.hello

import plus.yumeyuka.yumebot.plugin.Plugin
import plus.yumeyuka.yumebot.plugin.annotations.OnGroupMessage
import plus.yumeyuka.yumebot.plugin.annotations.GroupKeyword
import plus.yumeyuka.yumebot.plugin.annotations.Priority
import plus.yumeyuka.yumebot.protocol.message.OB11GroupMessage
import plus.yumeyuka.yumebot.api.message.message

class HelloPlugin : Plugin() {
    override val id = "com.example.hello"
    override val name = "问候插件"
    override val version = "1.0.0"
    override val author = "YumeBot"
    override val description = "简单的问候插件示例"

    override suspend fun onEnable() {
        logger.info("问候插件已启动")
    }

    @OnGroupMessage
    @GroupKeyword("你好", "hello")
    @Priority(100)
    suspend fun onHello(event: OB11GroupMessage) {
        val reply = message {
            at(event.sender.userId)
            text(" 你好!很高兴见到你")
        }.build()
        
        messageApi?.sendGroupMessage(event.groupId, reply, name)
    }
}

技术栈

Kotlin 2.0+

现代化 JVM 语言,简洁高效

Kotlin Coroutines

协程支持,异步编程

NapCatQQ

基于 QQNT 的现代化 QQ 机器人框架

Gradle KTS

Kotlin DSL 构建脚本

相关链接