Shiro
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
- OneBot
- pbbot-spring-boot-starter Shiro开发时的参考实现,感谢 lz1998 大佬的开源项目,本项目众多灵感正来源于此。
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