Marco de desarrollo rápido del robot QQ basado en el protocolo OneBot
Documentación · Descargar · Inicio rápido · Contribuir
A partir de la versión
v2
solo se admitenJDK 17+
ySpringBoot 3.0.0+
.Consulte la guía de migración de la documentación del proyecto v2 para obtener más detalles.
Al introducir dependencias, reemplace la versión
latest
con la última versión real deMaven Central
< dependency >
< groupId >com.mikuac</ groupId >
< artifactId >shiro</ artifactId >
< version >latest</ version >
</ dependency >
implementation( " com.mikuac:shiro:latest " )
implementation ' com.mikuac:shiro:latest '
Escriba el archivo de configuración
application.yaml
o consulte el archivo de configuración avanzada
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
MESSAGE_BLOCK
los complementos posteriores no se ejecutarán.Escriba el archivo de configuración
application.yaml
o consulte el archivo de configuración avanzada
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 se desarrolla utilizando el protocolo estándar OneBot-v11 y es compatible con todos los clientes del protocolo OneBot que admiten WebSocket inverso.
proyecto | describir | Observación |
---|---|---|
LLOneBot | Haga que su NTQQ admita el protocolo OneBot11 para el desarrollo de robots QQ | |
Lagrange.Core | Implementación del protocolo NTQQ | |
ir-cqhttp | Implementación nativa de OneBot Golang basada en Mirai y MiraiGo | Detener el mantenimiento |
AbrirTrébol | Implementar el marco de robot estándar OneBot basado en Xposed |
Consulte Contribuir para obtener más detalles. ¡Gracias a todas las personas que ya contribuyeron!
Este producto tiene la licencia GNU General Public License versión 3. La licencia es la publicada por la Free Software Foundation en https://www.gnu.org/licenses/gpl-3.0.html.
Alternativamente, este producto tiene la licencia GNU Lesser General Public License versión 3 para uso no comercial. La licencia es la publicada por la Free Software Foundation en https://www.gnu.org/licenses/lgpl-3.0.html. .
No dude en contactarnos si tiene alguna pregunta sobre licencias o desea utilizar la biblioteca en un producto comercial de código cerrado.
JetBrains ofrece licencias gratuitas para respaldar proyectos de código abierto.