กรอบการพัฒนาหุ่นยนต์ QQ อย่างรวดเร็วโดยใช้โปรโตคอล OneBot
เอกสารประกอบ · ดาวน์โหลด · เริ่มต้นอย่างรวดเร็ว · มีส่วนร่วม
ตั้งแต่เวอร์ชัน
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 และเข้ากันได้กับไคลเอ็นต์โปรโตคอล OneBot ทั้งหมดที่รองรับ Reverse WebSocket
โครงการ | อธิบาย | หมายเหตุ |
---|---|---|
แอลวันบอต | ทำให้ NTQQ ของคุณรองรับโปรโตคอล OneBot11 สำหรับการพัฒนาหุ่นยนต์ QQ | |
ลากรองจ์.คอร์ | การใช้โปรโตคอล NTQQ | |
ไป-cqhttp | การใช้งาน OneBot Golang แบบเนทิฟบน Mirai และ MiraiGo | หยุดการบำรุงรักษา |
เปิดแชมร็อก | ใช้เฟรมเวิร์กโรบอตมาตรฐาน OneBot บน Xposed |
ดูรายละเอียดการมีส่วนร่วม ขอบคุณทุกคนที่มีส่วนร่วมแล้ว!
ผลิตภัณฑ์นี้ได้รับอนุญาตภายใต้ GNU General Public License เวอร์ชัน 3 ใบอนุญาตดังกล่าวเผยแพร่โดย Free Software Foundation ซึ่งเผยแพร่ที่ https://www.gnu.org/licenses/gpl-3.0.html
อีกทางหนึ่ง ผลิตภัณฑ์นี้ได้รับอนุญาตภายใต้ GNU Lesser General Public License เวอร์ชัน 3 สำหรับการใช้งานที่ไม่ใช่เชิงพาณิชย์ ใบอนุญาตนี้เผยแพร่โดย Free Software Foundation ที่เผยแพร่ที่ https://www.gnu.org/licenses/lgpl-3.0.html .
โปรดติดต่อเราหากคุณมีคำถามใดๆ เกี่ยวกับใบอนุญาตหรือต้องการใช้ห้องสมุดในผลิตภัณฑ์แหล่งปิดเชิงพาณิชย์
JetBrains เสนอใบอนุญาตฟรีเพื่อสนับสนุนโครงการโอเพ่นซอร์ส