Comments (2)
感激不尽
from chatgpt-yourchatrobot.
如果你想实现**在群聊里只有当别人@机器人时,才会回复。**可以考虑将获取到的消息元素进行筛选,若筛选到@机器人的消息,再向ChatGPT提问并回复,比如:
@EventHandler
public void onMessage(@NotNull MessageEvent event) {
ChatBO chatBO = new ChatBO();
chatBO.setSessionId(String.valueOf(event.getSender().getId()));
chatBO.setQuestion(event.getMessage().contentToString());
if(event.getBot().getGroups().contains(event.getSubject().getId())) {
//如果是在群聊
//遍历收到的消息元素
for (SingleMessage singleMessage : event.getMessage()) {
if (singleMessage.equals(new At(event.getBot().getId()))) {
//存在@机器人的消息就向ChatGPT提问
event.getSubject().sendMessage(interactService.chat(chatBO));
break;
}
}
}else
//不是在群聊 则直接回复
event.getSubject().sendMessage(interactService.chat(chatBO));
}
你可以将以上代码copy到项目里替换原来的onMessage函数来直接使用。
其他的设定可以参考mirai的文档,后续我也会增加这类设定功能,谢谢你的提问🌹
from chatgpt-yourchatrobot.
Related Issues (20)
- 增加Bing ai支持 HOT 1
- Suggestion to add a license file to the repository HOT 1
- itchat4j-1.1.0-jar-with-dependencies.jar中没有主清单属性 HOT 3
- 想请教一下大佬是如何使用二维码登录mirai的,求教原理和配置方式 HOT 2
- QQ扫码登录提示要同一网络下,请问怎么提取到登录的缓存 HOT 2
- qq HOT 1
- jar文件运行不起来 HOT 4
- 断网需要重启 HOT 1
- 推荐使用 `devlive-community/openai-java-sdk` HOT 1
- 当前设备网络不稳定 HOT 9
- 访问gpt后响应429, 我的key是刚获取的 HOT 2
- DALL·E 3模型问题 HOT 3
- 可以用第三方的Key吗 HOT 2
- 微信群GPT回复时: “@提问人” 可以实现吗 HOT 1
- 是否考虑支持第三方反代API服务? HOT 2
- 关于AI语音/图片回复的bug
- 能不能让它调用本地浏览器访问网页,以及使用百度/Google搜索,把取到的网页数据交给gpt处理? HOT 8
- qq群消息发不出来 HOT 1
- 发消息有问题
- 你好 如果qq发送的问题比较多 就比较慢 能弄个多线程回复吗 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatgpt-yourchatrobot.