OneBot 프로토콜을 기반으로 한 QQ 로봇 신속한 개발 프레임워크
문서 · 다운로드 · 빠른 시작 · 기여
버전
v2
부터JDK 17+
및SpringBoot 3.0.0+
만 지원됩니다.자세한 내용은 프로젝트 설명서 v2 마이그레이션 가이드를 참조하세요.
종속성을 도입할 때
latest
버전을Maven Central
의 실제 최신 버전으로 교체하세요.
< dependency >
< groupId >com.mikuac</ groupId >
< artifactId >shiro</ artifactId >
< version >latest</ version >
</ dependency >
implementation( " com.mikuac:shiro:latest " )
implementation ' com.mikuac:shiro:latest '
application.yaml
구성 파일을 작성하거나 고급 구성 파일을 참조하세요.
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
반환하면 후속 플러그인은 실행되지 않습니다.
application.yaml
구성 파일을 작성하거나 고급 구성 파일을 참조하세요.
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는 OneBot-v11 표준 프로토콜을 사용하여 개발되었으며 역방향 WebSocket을 지원하는 모든 OneBot 프로토콜 클라이언트와 호환됩니다.
프로젝트 | 설명하다 | 주목 |
---|---|---|
LLOneBot | QQ 로봇 개발을 위해 NTQQ가 OneBot11 프로토콜을 지원하도록 만드세요. | |
라그랑주.코어 | NTQQ 프로토콜 구현 | |
go-cqhttp | Mirai 및 MiraiGo를 기반으로 한 OneBot Golang 기본 구현 | 유지보수 중지 |
오픈샴록 | Xposed를 기반으로 OneBot 표준 로봇 프레임워크 구현 |
자세한 내용은 기여를 참조하세요. 이미 기여해 주신 모든 분들께 감사드립니다!
이 제품은 GNU General Public License 버전 3에 따라 라이센스가 부여되었습니다. 라이센스는 자유 소프트웨어 재단(https://www.gnu.org/licenses/gpl-3.0.html)에서 게시한 대로입니다.
또는 이 제품은 비상업적 사용을 위한 GNU Lesser General Public License 버전 3에 따라 라이센스가 부여됩니다. 라이센스는 자유 소프트웨어 재단에서 게시한 https://www.gnu.org/licenses/lgpl-3.0.html에 따릅니다. .
라이센스에 대해 질문이 있거나 상용 비공개 소스 제품에서 라이브러리를 사용하려는 경우 언제든지 문의해 주세요.
JetBrains는 오픈 소스 프로젝트를 지원하기 위한 무료 라이선스를 제공합니다.