这是一个spring boot starter,可以用于快速开发对应于 Go-Mirai-Client,pbrq 或 Spring-Mirai-Client 的消息处理中心。
仅用于编写业务逻辑,不涉及登陆等功能,建议配合pbrq使用,下载地址:pbrq-Release
文档:https://blog.lz1998.net/blogs/bot/2020/pbbot-doc/
例子:https://github.com/ProtobufBot/Spring-Mirai-Server
- pom.xml
<dependency>
<groupId>net.lz1998</groupId>
<artifactId>pbbot-spring-boot-starter</artifactId>
<version>0.0.38</version>
</dependency>
- HelloPlugin
package com.example.demo.plugin;
import net.lz1998.pbbot.bot.Bot;
import net.lz1998.pbbot.bot.BotPlugin;
import net.lz1998.pbbot.utils.Msg;
import onebot.OnebotEvent;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
@Component
public class HelloPlugin extends BotPlugin {
@Override
public int onPrivateMessage(@NotNull Bot bot, @NotNull OnebotEvent.PrivateMessageEvent event) {
Msg msg = Msg.builder()
.text("123")
.face(1);
bot.sendPrivateMsg(event.getUserId(), msg.build(), false);
return super.onPrivateMessage(bot, event);
}
}
- application.yml
spring:
bot:
plugin-list:
- com.example.demo.plugin.HelloPlugin
server:
port: 8081