Coder Social home page Coder Social logo

simple-robot / simpler-robot Goto Github PK

View Code? Open in Web Editor NEW
502.0 6.0 43.0 102.11 MB

Simple Robot,一个bot风格的高效异步事件调度框架 / A Bot-style event scheduling framework, asynchronous and high-performance

Home Page: https://simbot.forte.love

License: GNU Lesser General Public License v3.0

Kotlin 99.01% Java 0.88% CSS 0.06% FreeMarker 0.05%
simbot simple-robot bot qqbot kook-bot qq-bot qq-guild-bot java kotlin bot-framework

simpler-robot's Introduction

simbot logo

- Simple Robot -

~ simbot v4 ~
GitHub    |    Gitee
> 感谢 CatCode 开发团队成员制作的simbot logo <
> 走过路过,不要忘记点亮一颗⭐喔~ <
release release doc Qodana
stars forks watchers repo-size code-size issues last-commit search-hit top-language copying

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🌟 便是能够给予我们继续走下去的最大动力与支持!

  • 阅读 贡献指南 来了解如何贡献你的力量!
  • 你可以通过 讨论区 与其他人或者simbot开发团队相互友好交流。
  • 如果你通过此项目创建了一个很酷的开源项目,欢迎通过 ISSUES讨论区 等方式留下你的开源项目信息,并将你酷酷的项目展示在作品展示区。

联系我们

  • 如果想要反馈问题、提出建议建议或提出问题,请通过 ISSUES
  • 如果想要与开发团队交流、与其他开发者交流,请前往 讨论区
  • 可以前往 GitHub 组织首页 查看更多社群信息

特别鸣谢

jetbrains

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

simpler-robot's People

Contributors

dependabot[bot] avatar forliyscarlet avatar fortescarlet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simpler-robot's Issues

[BUG] 根据微信群号获取群信息异常

version: 2.0.0-BETA.6
java: 8_261

module: 可爱猫-httpapi

问题描述

根据群号获取群成员异常

相关日志

https://paste.ubuntu.com/p/2RTJbb62gg/

复现方式

@Listen(GroupMsg.class)
    public void testGroup(GroupMsg msg, MsgSender sender) {
        System.out.println("收到群消息:" + msg.getMsg());

        System.out.println(sender.GETTER.getGroupInfo(msg));

        for (GroupMemberInfo groupMemberInfo : sender.GETTER.getGroupMemberList(msg)) {
            System.out.println(groupMemberInfo);
        }

[QUE] mirai组件多行文本控制台显示不全

version: 2.0.0-RC.1``

module: ``

问题描述

@listen(GroupMsg.class)
public void GroupMessage(GroupMsg msg,MsgSender sender){

    System.out.println(msg.getMsg());
}

假设接收到一个换行群消息:
Test
Test
Test
通过System.out.println(msg.getMsg());仅能得到最后一个Test

相关日志

复现方式

@listen(GroupMsg.class)
public void GroupMessage(GroupMsg msg,MsgSender sender){

    System.out.println(msg.getMsg());
}

假设接收到一个换行群消息:
Test
Test
Test
通过System.out.println(msg.getMsg());仅能得到最后一个Test

[SUG] 提供默认送信器接口

提供一种配置以实现多个 默认送信器 方案,例如对于不支持的API来讲,严格模式下会抛出异常,而兼容模式下则会返回一个默认常量,警告模式则会输出警告日志等。

[FEAT] 优化监听函数注册时,监听类型与实际参数不符的情况

// 监听函数解析期间会输出警告日志,因为你监听了 GroupMsg, 而参数中的 PrivateMsg 却没有被监听,它在触发监听时会抛出异常。
@OnGroup
public void listen(PrivateMsg msg) {
    // ...    
}
// 监听函数解析期间会输出警告日志,因为你监听了 GroupMsg, 而参数中的 PrivateMsg 却没有被监听,它将永远为null。
@OnGroup
public void listen(@Depend(orIgnore = true) PrivateMsg msg) {
    // ...    
}

[FEAT] 细化账号信息容器

细化账号信息容器(AccountInfo)的子类型, 例如好友账号信息容器、群成员账号信息容器等。

[SUG] 优化事件触发机制

优化事件触发机制,当尝试触发一个不存在/未注册的事件类型的时候,不会真正触发事件流程。

[BUG] @ListenBreak未实现

version: 2.0.0-ALPHA.7

module: ``

疑问描述

两个监听器,第一个监听器A用了PriorityConstant.FIRST标记第一个执行,第二个监听器B是用@OnPrivate,所以应该是默认的PriorityConstant.TENTH,最后一个执行,A监听器使用了@ListenBreak注解,想要实现A监听器执行成功后不执行B监听器,但是最后两个监听器都执行了。

[BUG] 监听新人入群事件获取OperatorInfo报NPE

version: 2.0.0-ALPHA.10

module: ``

问题描述

监听新人入群事件时,从GroupMemberIncrease中获取OperatorInfo报NPE异常

相关日志

相关代码
@OnGroupMemberIncrease
public void groupMemberIncreaseListener(GroupMemberIncrease increaseMsg, MsgSender sender) {
log.info("新增了一名群成员");
long operatorCode = Objects.requireNonNull(increaseMsg.getOperatorInfo()).getOperatorCodeNumber();

复现方式

监听新人入群事件

[FEAT] @Filter支持定向过滤

使@Filter不再仅局限于通过msg.text进行过滤,而是支持解析一个简单的表达式来允许通过其他目标进行过滤,例如ListenContext中的某个元素。

[BUG] @Filter(anyAt = true) 无效

version: v2.0.0-ALPHA.12

module: core

@Filter(anyAt = true) 无效,实际表现等同于 @Filter(anyAt = false), 仅 @Filters(anyAt = true) 才会生效。

[BUG] http-client-ktor 模块依赖 serialization-json-core 而未提供默认的实现模块导致mirai组件启动报错。

version: 2.0.0-ALPHA.5

module: http-client-ktor

问题描述

http-client-ktor 模块依赖serialization-json-core 而未提供默认的实现模块导致依赖注入失败,会导致mirai组件启动报错。

临时解决方案:
pom中追加:

        <dependency>
            <groupId>love.forte.simple-robot</groupId>
            <artifactId>serialization-json-fastjson</artifactId>
        </dependency>

下一个 alpha.6 版本修复。

[BUG] 发送多个消息导致锁异常

version: v2.0.0-ALPHA.9

module: component-mirai

问题描述

当一次性发送多个图片的时候,会导致出现同步锁异常。

解决方案

移除同步锁,并追加图片复述时的优化方案。

[BUG] @Filter未匹配正则表达式

version: `` 2.0.0-BETA.6

module: `` core

问题描述

@filter 对于其中正则表达式解析似乎不太对

相关日志

复现方式

@OnPrivate @Filter(value = ".*A.*") public void A(PrivateMsg msg, MsgSender sender) { System.out.println("A->A"); }

方法如上 此监听的正则表达式好像没有生效,仅当我输入.*A.*时,监听才会触发
注:@ongroup中匹配似乎是正常的

[BUG]

version: v2.0.0-ALPHA.4-v2.0.0-ALPHA.5

module: core

问题描述

v2.0.0-ALPHA.4 版本更新后会导致任何不存在 文本消息(text) 的事件消息被所有监听函数触发。
此问题将会在 v2.0.0-ALPHA.6 版本修复。

[FEAT] 允许kotlin可空参数默认置null

// myBean 可以为null,因此如果依赖管理找不到此实例则会得到null值,而不是抛出异常。
@OnGroup
fun listen(msg: GroupMsg, myBean: MyBean?) {
    // ...
}

[BUG]

version: B7

module: CatCode

问题描述

CatCodeUtil.getInstance().getNekoList(msg, "at")
获取不到消息内容里面的猫猫码

相关日志

复现方式

自定义过滤器MostMatchType失效

version: 2.0.0-BETA.7

module: filter

问题描述

监听器上加两个自定义过滤器,后面指定匹配规则失效
测试了两个方法,分别指定了mostMatchType = MostMatchType.ALL和mostMatchType = MostMatchType.ANY
都只执行了第一个过滤器,第一个过滤器返回true的情况下不会执行第二个过滤器,直接执行监听事件,第一个返回false才会执行第二个过滤器

相关日志

复现方式

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.