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 プロトコル クライアントと互換性があります。
プロジェクト | 説明する | 述べる |
---|---|---|
LLワンボット | NTQQ で QQ ロボット開発用の OneBot11 プロトコルをサポートするようにする | |
ラグランジュコア | NTQQプロトコルの実装 | |
go-cqhttp | Mirai および MiraiGo に基づく OneBot Golang ネイティブ実装 | メンテナンスの停止 |
オープンシャムロック | XusedをベースにしたOneBot標準ロボットフレームワークを実装 |
詳細については、「貢献」を参照してください。すでに貢献してくださったすべての方々に感謝します。
この製品は、GNU General Public License バージョン 3 に基づいてライセンスされています。このライセンスは、https://www.gnu.org/licenses/gpl-3.0.html で公開されている Free Software Foundation によって公開されています。
あるいは、この製品は非営利目的の GNU Lesser General Public License バージョン 3 に基づいてライセンスされており、このライセンスは https://www.gnu.org/licenses/lgpl-3.0.html で公開されている Free Software Foundation によって公開されています。 。
ライセンスについてご質問がある場合、または商用のクローズド ソース製品でライブラリを使用したい場合は、お気軽にお問い合わせください。
JetBrains は、オープンソース プロジェクトをサポートするための無料ライセンスを提供します。