Skip to content

SaltifyDev/saltify

Repository files navigation

Saltify

跨平台 & 可扩展的 QQ Bot 框架

QQ 群 | Telegram

模块说明

  • saltify - 框架核心模块,程序启动的入口点,提供插件加载、命令路由、事件监听等功能。
  • saltify-web - Saltify 的 Web UI,提供插件管理、Bot 状态监控等功能。
  • saltify-api - 框架 API 模块,包含 Bot 开发所需的基础数据结构(如好友、群、群成员、消息、消息段)、事件的定义以及插件 DSL 的核心 API,需要在开发插件时引入
  • adapter - 目前包含以下实现:
  • saltify-utils - 私有模块,提供框架和适配器通用的工具类和函数。

插件 DSL 示例

class Config(
    val echoPrefix: String = "::"
)

val plugin = definePlugin<Config> {
    onStart {
        println("Plugin started")
        // do something with side effects
    }

    command("echo") {
        // define command parameters in order
        val pMessage = parameter<String>("message", "The message to echo")
        onExecute {
            val message = capture(pMessage)
            respond {
                image(remote("https://example.com/image.png"))
                text("${config.echoPrefix} $message")
            }
        }
    }
    
    on<GroupJoinRequestEvent> {
        val group = it.ctx.getGroup(it.groupUin)
        group?.sendMessage("${it.initiatorUin} requested to join group with ${it.comment}")
    }
    
    onStop { 
        // do something to clear side effects
    }
}

About

跨平台 & 可扩展的 QQ Bot 框架,支持插件加载、命令路由、事件监听等

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •