基于OneBot协议的QQ机器人快速开发框架

Related tags

Shiro
Overview

Shiro

基于 OneBot 协议的 QQ机器人 快速开发框架

maven issues license jdk-version qq-group cqhttp

QuickStart

<!-- 导入Maven依赖 -->
<dependency>
    <groupId>com.mikuac</groupId>
    <artifactId>shiro</artifactId>
    <version>1.1.1</version>
</dependency>
# 修改application.yaml
server:
  port: 5555

shiro:
  # 全局限速器 (基于令牌桶算法),无需该配置字段可删除,将使用默认值(默认禁用)
  limiter:
    enable: false
    permits-per-second: 1
  # Webscoket连接地址,无需该配置字段可删除,将使用默认值 "/ws/shiro"
  ws-config:
    ws-url: "/ws/shiro"
  # 插件列表 (顺序执行,如果前一个插件返回了MESSAGE_BLOCK,将不会执行后续插件)
  plugin-list:
    - com.mikuac.bot.plugins.ExamplePlugin
// 继承BotPlugin开始编写插件
@Component
public class ExamplePlugin extends BotPlugin {

    @Override
    public int onPrivateMessage(@NotNull Bot bot, @NotNull PrivateMessageEvent event) {
        // 构建消息
        MsgUtils msgUtils = MsgUtils().builder().face(66).text("Hello, this is shiro demo.");
        // 发送私聊消息
        bot.sendPrivateMsg(event.getUserId(), msgUtils.build(), false);
        // 返回 MESSAGE_IGNORE 插件向下执行,返回 MESSAGE_BLOCK 则不执行下一个插件
        return MESSAGE_IGNORE;
    }

    @Override
    public int onGroupMessage(@NotNull Bot bot, @NotNull GroupMessageEvent event) {
        // 构建消息
        MsgUtils msgUtils = MsgUtils().builder().at(event.getUserId()).face(66).text("Hello, this is shiro demo.");
        // 发送群消息
        bot.sendGroupMsg(event.getGroupId(), msgUtils.build(), false);
        // 返回 MESSAGE_IGNORE 插件向下执行,返回 MESSAGE_BLOCK 则不执行下一个插件
        return MESSAGE_IGNORE;
    }

}

Client

Shiro 以 OneBot-v11 标准协议进行开发,兼容所有支持反向WebSocket的OneBot协议客户端

项目地址 平台 核心作者 备注
Yiwen-Chan/OneBot-YaYa 先驱 kanri
richardchien/coolq-http-api CKYU richardchien 可在 Mirai 平台使用 mirai-native 加载
Mrs4s/go-cqhttp MiraiGo Mrs4s
yyuueexxiinngg/cqhttp-mirai Mirai yyuueexxiinngg
takayama-lily/onebot OICQ takayama

Feature

完善中···

目前已实现绝大部分Event,Action,CQCode,请自行查看源码

Credits

License

This product is licensed under the GNU General Public License version 3. The license is as published by the Free Software Foundation published at https://www.gnu.org/licenses/gpl-3.0.html.

Alternatively, this product is licensed under the GNU Lesser General Public License version 3 for non-commercial use. The license is as published by the Free Software Foundation published at https://www.gnu.org/licenses/lgpl-3.0.html.

Feel free to contact us if you have any questions about licensing or want to use the library in a commercial closed source product.

Thanks

Thanks JetBrains Provide Free License Support OpenSource Project

Stargazers over time

Stargazers over time

Issues
  • 【请求】ShiroUtils 新增支援获取一则消息内多张图片

    【请求】ShiroUtils 新增支援获取一则消息内多张图片

    我测试了发现如果在一则消息内有多张图片会出现只能获取第一张的问题,希望新增对其支援

    bug 
    opened by eric2788 6
  • [请求] ActionPathEnum 提供可扩展方式

    [请求] ActionPathEnum 提供可扩展方式

    是这样的,我在 go-cqhttp 看到的一些 request 发现在 ActionPathEnum 没有提供 (例如群精华消息,我找不到) ,于是便打算自行调用 ActionHandler 去做自定义的 API 请求。

    但我发现 Enum 是没办法自行使用反射创建的,而且你的 ActionHandler 的 doActionRequest 方法中只能放入 ActionPathEnum 作为请求,因此我现在无法做自定义的 API 请求。如果要在不修改API源代码的前提下做,我只能重新实作一个新的 ActionHandler ,并使用反射获取现有 ActionHandler 的所有实例,极其麻烦。

    如果此API会持续更新的话,我就需要每次有新的更新都要修改本API源代码一次,很麻烦。因此我希望你能接受 pull request ? 或者由作者本人去修改。

    为 ActionPathEnum 提供可扩展方式很简单,只要创建一个 interface 去定义 enum 的方法 然后由 ActionPathEnum 去继承,最后 ActionHandler 的 doActionRequest 方法 接收 该 Interface 作为参数而不是 ActionPathEnum 就可以了。

    public interface ActionPath {
    
      String getDesc();
      
      String getPath();
    
    }
    
    public enum ActionPathEnum implements ActionPath {
    
         SOME_ACTION("do_action", "某个请求"); // 更多如此类推
    
         private final String path;
         private final String desc;
        
        @Override
        public String getPath() {
            return this.path;
        }
    
        @Override
        public String getDesc() {
            return this.desc;
        }
    
        private ActionPathEnum(String path, String desc) {
            this.path = path;
            this.desc = desc;
        }
    }
    
    @Component
    public class ActionHandler {
         // ....
         public JSONObject doActionRequest(WebSocketSession session, ActionPath action, JSONObject params) {
            // ....
            String path = action.getPath();
            String desc = action.getDesc();
            // .....
         }
         // .....
    }
    
    enhancement 
    opened by eric2788 2
  • [問題] FriendAddRequestEvent 沒有繼承 RequestEvent 故無法獲取 flag 值

    [問題] FriendAddRequestEvent 沒有繼承 RequestEvent 故無法獲取 flag 值

    如題.... 還是有別的方法可以獲取 flag 來接受好友請求?

    bug 
    opened by eric2788 2
  • ⬆️ Bump maven-javadoc-plugin from 3.3.0 to 3.3.1

    ⬆️ Bump maven-javadoc-plugin from 3.3.0 to 3.3.1

    Bumps maven-javadoc-plugin from 3.3.0 to 3.3.1.

    Commits
    • 2d22cca [maven-release-plugin] prepare release maven-javadoc-plugin-3.3.1
    • 7b7813e [MJAVADOC-450] Artifacts with a classifier are ignored when looking for resou...
    • 0d0e0cc [MJAVADOC-618] Goal javadoc:aggregate fails with submodules packaged as war
    • a2acaa2 [MJAVADOC-137] transform verify script from bsh to groovy
    • 16ca119 Clean up slf4j-simple
    • 87dbfb2 [MJAVADOC-677] Using "requires static transitive" makes javadoc goal fail
    • d770460 [MJAVADOC-680] JDK 16+: Error fetching link: ...\target\javadoc-bundle-option...
    • 292ebb7 Bump slf4j-simple from 1.7.30 to 1.7.32
    • fe6d738 Bump mockito-core from 3.9.0 to 3.12.0
    • d2dd532 [MJAVADOC-679] "Unable to compute stale date" in a directory with accent char...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • [瞳孔震惊] UnsupportedClassVersionError

    [瞳孔震惊] UnsupportedClassVersionError

    哇靠我看了一下怎么jdk 15+

    可否提供jdk8的编译,虽然我个人是拥抱新版本

    但是部分依赖 确实不支持jdk8以上..

    enhancement 
    opened by Zhongren233 2
Releases(v1.1.4)
Owner
MisakaTAT
凉风乍起,一叶知秋。
MisakaTAT