Skip to content

Latest commit

 

History

History
205 lines (163 loc) · 8.29 KB

File metadata and controls

205 lines (163 loc) · 8.29 KB
simbot logo

- Simple Robot -

~ simbot ~
GitHub    |    Gitee
> Thanks to the members of the CatCode development team for creating the simbot logo <
> Passing by? Don't forget to light up a ⭐~ <
release release doc Qodana Ask DeepWiki
stars forks watchers repo-size code-size issues top-language copying

中文

Introduction

Simple Robot is a high-performance asynchronous event scheduling framework in the Bot style that is built on Kotlin coroutines and Kotlin Multiplatform (hereinafter referred to as simbot), delivering efficient asynchrony and Java-friendly APIs.

simbot provides a unified asynchronous API and an intuitive design style to help you create Bot-style event-driven applications quickly and efficiently. It is mainly used to integrate with a wide variety of bot application platforms/frameworks, and it already offers several component library implementations.

[!info] Since version 5.0, all components maintained and stabilized by our team have been merged into the current core repository for unified maintenance.

simbot's platform capabilities are component-driven. Install different component libraries to gain support for different features.

For example, using KOOK and QQ components in simbot:

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

fun ApplicationFactoryConfigurer<*, *, *>.config() {
    // Install the KOOK and QQ components
    useKook()
    useQQGuild()
}

/**
 * Configure and apply the built `Application`
 */
suspend fun Application.module() {
    registerBots()
    registerListeners()
}

/**
 * Register the required bots
 */
suspend fun Application.registerBots() {
    // Register a KOOK bot so KOOK-related events can be handled afterwards
    kookBots {
        register(...) { ... }.start()
    }

    // Register a QQ Guild bot so QQ Guild-related events can be handled afterwards
    qqGuildBots {
        register(...) { ... }.start()
    }
}

fun Application.registerListeners() {
    listeners {
        // Register an event handler
        // ChatChannelMessageEvent is a generic type defined by the simbot API representing all sub-channel message events
        // This includes QQ Guild public channel message events and KOOK channel message events
        listen<ChatChannelMessageEvent> {
            println("context: $this")
            println("context.event: $event")

            // Return the event handling result
            EventResult.empty()
        }

        // Register another event handler
        // Explicitly listen for QQ Guild public channel message events
        // Using process eliminates the need to return a value
        process<QGAtMessageCreateEvent> {
            println("context: $this")
            println("context.event: $event")
        }

        // Register one more event handler
        // Explicitly listen for KOOK channel message events
        // Using process eliminates the need to return a value
        process<KookChannelMessageEvent> {
            println("context: $this")
            println("context.event: $event")
        }
    }
}

Documentation & Guides

Support Us

Lighting up a ✨star🌟 for us is the greatest motivation and support for keeping the project going!

  • Read the Contribution Guide to learn how you can contribute!
  • Join the conversation with others or the simbot development team via the Discussions.
  • If you have created an awesome open-source project based on simbot, feel free to share it via ISSUES or Discussions so we can showcase your cool project in the gallery.

Contact Us

  • To report issues, make suggestions, or ask questions, please use ISSUES.
  • To communicate with the development team or other developers, head to Discussions.
  • Visit the GitHub Organization Homepage for more community information.

Special Thanks

jetbrains

Thanks to JetBrains for providing the team with free licenses. We also encourage everyone to support JetBrains, its products, and genuine software.

Stars!

Star History Chart

powered by Star History

License

Simple Robot is open-sourced under the LGPLv3 license.

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/>.