QQ robotic rapid development framework based on the ONEBOT protocol
Document · Download · Quick Start · Participate in Contribution
From
v2
version, onlyJDK 17+
andSpringBoot 3.0.0+
For details, see the project document V2 migration guide
When introducing dependence, please replace the version of
latest
as the latest version ofMaven Central
.
< dependency >
< groupId >com.mikuac groupId >
< artifactId >shiro artifactId >
< version >latest version >
dependency >
implementation( " com.mikuac:shiro:latest " )
implementation ' com.mikuac:shiro:latest '
Write the
application.yaml
configuration file or refer to the advanced configuration file
server :
port : 5000
@ Shiro
@ Component
public class ExamplePlugin {
// 更多用法详见 @MessageHandlerFilter 注解源码
// 当机器人收到的私聊消息消息符合 cmd 值 "hi" 时,这个方法会被调用。
@ PrivateMessageHandler
@ MessageHandlerFilter ( cmd = "hi" )
public void fun1 ( Bot bot , PrivateMessageEvent event , Matcher matcher ) {
// 构建消息
String sendMsg = MsgUtils . builder (). face ( 66 ). text ( "Hello, this is shiro demo." ). build ();
// 发送私聊消息
bot . sendPrivateMsg ( event . getUserId (), sendMsg , false );
}
// 如果 at 参数设定为 AtEnum.NEED 则只有 at 了机器人的消息会被响应
@ GroupMessageHandler
@ MessageHandlerFilter ( at = AtEnum . NEED )
public void fun2 ( GroupMessageEvent event ) {
// 以注解方式调用可以根据自己的需要来为方法设定参数
// 例如群组消息可以传递 GroupMessageEvent, Bot, Matcher 多余的参数会被设定为 null
System . out . println ( event . getMessage ());
}
// 同时监听群组及私聊消息 并根据消息类型(私聊,群聊)回复
@ AnyMessageHandler
@ MessageHandlerFilter ( cmd = "say hello" )
public void fun3 ( Bot bot , AnyMessageEvent event ) {
bot . sendMsg ( event , "hello" , false );
}
}
plugin-list
resources/application.yaml
adds the following contentMESSAGE_BLOCK
list is executed in order.Write the
application.yaml
configuration file or refer to the advanced configuration file
server :
port : 5000
shiro :
plugin-list :
- com.example.bot.plugins.ExamplePlugin
@ Component
public class ExamplePlugin extends BotPlugin {
@ Override
public int onPrivateMessage ( Bot bot , PrivateMessageEvent event ) {
if ( "hi" . equals ( event . getMessage ())) {
// 构建消息
String sendMsg = MsgUtils . builder ()
. face ( 66 )
. text ( "hello, this is shiro example plugin." )
. build ();
// 发送私聊消息
bot . sendPrivateMsg ( event . getUserId (), sendMsg , false );
}
// 返回 MESSAGE_IGNORE 执行 plugin-list 下一个插件,返回 MESSAGE_BLOCK 则不执行下一个插件
return MESSAGE_IGNORE ;
}
@ Override
public int onGroupMessage ( Bot bot , GroupMessageEvent event ) {
if ( "hi" . equals ( event . getMessage ())) {
// 构建消息
String sendMsg = MsgUtils . builder ()
. at ( event . getUserId ())
. face ( 66 )
. text ( "hello, this is shiro example plugin." )
. build ();
// 发送群消息
bot . sendGroupMsg ( event . getGroupId (), sendMsg , false );
}
// 返回 MESSAGE_IGNORE 执行 plugin-list 下一个插件,返回 MESSAGE_BLOCK 则不执行下一个插件
return MESSAGE_IGNORE ;
}
}
Shiro is developed with the ONEBOT-V11 standard protocol, which is compatible with all Onebot protocol clients that support the reverse WebSocket
project | describe | Remark |
---|---|---|
Llonebot | Make your NTQQ support the Onebot11 protocol for QQ robot development | |
Lagrange.core | NTQQ protocol implementation | |
GO-CQHTTP | ONEBOT Golang native implementation based on Mirai and Miraigo | Stop maintenance |
OpenShamrock | Robot framework based on the ONEBOT standard based on XPOSED |
See Contributing for Details. Thanks to All the People Who ALREADY CONTRIBUTED!
This product is licensed under the gnu general publicing version. 3. The License is As Published by the Free Software Foundation Public AT: //www.g. nu.org/licenses/gpl-3.0.html.
Alternatively, this Product is likensed under the gnu lesser general public life, 3 for non-composercial use. Rely Published at https://www.gnu.org/licenses/lgpl-3.0.html Then, then
Feel free to contal us if you have any questions about livensing or want to use the library in a commercial closece product.
JetBrains Offers FREE LICENSES to Support Open Source Projects.