Home

Awesome

<!--suppress HtmlDeprecatedAttribute --> <div align="center"> <a href="https://simbot.forte.love/"> <picture> <source media="(prefers-color-scheme: dark)" srcset=".simbot/logo-dark.svg"> <source media="(prefers-color-scheme: light)" srcset=".simbot/logo.svg"> <img alt="simbot logo" src=".simbot/logo.svg" width="260" /> </picture> </a> <h2> - Simple Robot - </h2> <small> ~ simbot v4 ~ </small> <br> <span> <a href="https://github.com/simple-robot/simpler-robot" target="_blank">GitHub</a> </span> &nbsp;&nbsp; | &nbsp;&nbsp; <span> <a href="https://gitee.com/simple-robot/simpler-robot" target="_blank">Gitee</a> </span> <br /> <small> &gt; 感谢 <a href="https://github.com/ForteScarlet/CatCode" target="_blank">CatCode</a> 开发团队成员制作的simbot logo &lt; </small> <br> <small> &gt; 走过路过,不要忘记点亮一颗⭐喔~ &lt; </small> <br> <a href="https://github.com/simple-robot/simpler-robot/releases/latest"><img alt="release" src="https://img.shields.io/github/v/release/simple-robot/simpler-robot" /></a> <a href="https://repo1.maven.org/maven2/love/forte/simbot/simbot-api/" target="_blank"> <img alt="release" src="https://img.shields.io/maven-central/v/love.forte.simbot/simbot-api" /></a> <a href="https://simbot.forte.love" target="_blank"> <img alt="doc" src="https://img.shields.io/badge/doc-simbot-brightgreen" /></a> <a href="https://qodana.cloud/projects/p9mmM/reports/79Xen" target="_blank"> <img alt="Qodana" src="https://github.com/simple-robot/simpler-robot/actions/workflows/qodana_code_quality.yml/badge.svg" /></a> <hr> <img alt="stars" src="https://img.shields.io/github/stars/simple-robot/simpler-robot" /> <img alt="forks" src="https://img.shields.io/github/forks/simple-robot/simpler-robot" /> <img alt="watchers" src="https://img.shields.io/github/watchers/simple-robot/simpler-robot" /> <img alt="repo-size" src="https://img.shields.io/github/repo-size/simple-robot/simpler-robot" /> <img alt="code-size" src="https://img.shields.io/github/languages/code-size/simple-robot/simpler-robot" /> <img alt="issues" src="https://img.shields.io/github/issues-closed/simple-robot/simpler-robot?color=green" /> <img alt="last-commit" src="https://img.shields.io/github/last-commit/simple-robot/simpler-robot" /> <img alt="search-hit" src="https://img.shields.io/github/search/simple-robot/simpler-robot/simbot" /> <img alt="top-language" src="https://img.shields.io/github/languages/top/simple-robot/simpler-robot" /> <a href="./COPYING"><img alt="copying" src="https://img.shields.io/github/license/simple-robot/simpler-robot" /></a> <br> </div>

English

简介

Simple Robot (v4) 是一个基于Kotlin协程Kotlin多平台 Bot风格高性能异步事件调度框架(下文简称simbot), 异步高效、Java友好~

simbot提供统一的异步API和易用的风格设计,可以协助你更快速高效的编写Bot风格的事件调度应用。 主要应用于对接各种类型的Bot应用平台/框架,并提供部分组件库实现。

simbot的平台功能由组件驱动,安装不同的组件库来获得不同的功能支持。

举个例子,在simbot中使用KOOK和QQ频道:

suspend fun main() {
    launchSimpleApplication { config() }
        .joinWith { module() }
}

fun ApplicationFactoryConfigurer<*, *, *>.config() {
    // 安装KOOK和QQ频道组件库
    useKook()
    useQQGuild()
}

/**
 * 对已经构建完成的 `Application` 进行配置于应用
 */
suspend fun Application.module() {
    registerBots()
    registerListeners()
}

/**
 * 注册所需的bot
 */
suspend fun Application.registerBots() {
    // ... 注册kook bot,并在此之后可处理到kook的相关事件
    kookBots {
        register(...) { ... }.start()
    }

    // ... 注册QQ频道bot,并在此之后可处理到QQ频道的相关事件
    qqGuildBots {
        register(...) { ... }.start()
    }
}

fun Application.registerListeners() {
    listeners {
        // 注册一个事件处理器
        // ChatChannelMessageEvent 是由simbot API定义的泛用类型,代表所有子频道消息事件
        // 其中就包括QQ频道的公域消息事件, 或者KOOK的频道消息事件
        listen<ChatChannelMessageEvent> {
            println("context: $this")
            println("context.event: $event")

            // 返回事件处理结果
            EventResult.empty()
        }

        // 再注册一个事件处理器
        // 明确监听QQ频道的公域消息事件
        // 使用 process 不需要返回值
        process<QGAtMessageCreateEvent> {
            println("context: $this")
            println("context.event: $event")
        }

        // 再注册一个事件处理器
        // 明确监听KOOK的频道消息事件
        // 使用 process 不需要返回值
        process<KookChannelMessageEvent> {
            println("context: $this")
            println("context.event: $event")
        }
    }
}

文档与引导

协助我们

为我们点亮一个 ✨star🌟 便是能够给予我们继续走下去的最大动力与支持!

联系我们

特别鸣谢

<a href="https://www.jetbrains.com/?from=simpler-robot"> <img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" width="200" alt="jetbrains" /> </a>

感谢 Jetbrains 为团队提供的免费授权,也希望大家能够支持 Jetbrains 及其产品,支持正版。

星星!

Star History Chart

powered by Star History

License

Simple Robot 使用 LGPLv3 协议开源。

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by 
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Lesser GNU General Public License for more details.

You should have received a copy of the Lesser GNU General Public License 
along with this program.  If not, see <https://www.gnu.org/licenses/>.