- 前言:知识与储备
- 这个QQ机器人能干什么?
- 第一步:搭建Maven项目环境
- 第二步:编写pom文件
- 第三步:编写启动类
- 第四步:创建配置文件
- 第五步:编写一个监听器并监听群消息
- 第六步:启动项目
- 可能遇到的问题:
- 滑块验证
- 遇到其他问题可加QQ群进行讨论
- 参考文档
前言:知识与储备根据框架来实现一个QQ机器人、阅读这篇文章你需要Java基础以及SpringBoot(方便快速集成一些框架)和Maven的基础。
详细参考此文档:https://www.yuque.com/simpler-robot/simpler-robot-doc/ehy6dz
这个QQ机器人能干什么?第一步:搭建Maven项目环境他可以监听并发送或者回复好友消息和群消息(比如群的禁言、At群成员等等 … )
此框架并没有具体的功能,你需要自己写代码来实现你所需的功能。
然后点击 完成
第二步:编写pom文件第三步:编写启动类4.0.0 org.example springboot-robot 1.0-SNAPSHOT 8 8 5.3.16 8 3.0.0.preview.8.1 3.0.0.0.preview.3.1 3.0.0.0.preview.2.2 org.springframework.boot spring-boot-starter-parent 2.6.6 org.springframework.boot spring-boot-starter-web love.forte.simbot.boot simboot-core-spring-boot-starter ${simbot.version} love.forte.simbot.component simbot-component-tencent-guild-boot ${simbot-component-tcg.version} love.forte.simbot.component simbot-component-mirai-boot ${simbot-component-mirai.version} org.springframework.boot spring-boot-maven-plugin
package com.ityifan;
import love.forte.simboot.autoconfigure.EnableSimbot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableSimbot
@SpringBootApplication
public class SpringBootRoBotApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootRoBotApplication.class, args);
}
}
目前包结构如下图:
package com.ityifan.listener;
import love.forte.simboot.annotation.Listener;
import love.forte.simbot.event.GroupMessageEvent;
import org.springframework.stereotype.Component;
@Component
public class GroupListener {
@Listener
public void repeat(GroupMessageEvent event){
// 获取群成员的消息
// getPlainText()为文本消息
final String message = event.getMessageContent().getPlainText();
//发送消息
event.getGroup().sendBlocking(message);
}
}
目前包结构:
运行启动器的main方法即可
可能遇到的问题: 滑块验证
QQ交流群连接:
群聊与艺术:https://www.yuque.com/simpler-robot/simpler-robot-doc/xklly8
参考文档:https://www.yuque.com/simpler-robot/simpler-robot-doc/xygygt
ityifan 禁止转载



