Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

严重BUG 自己和自己聊天 #93

Open
kwqseb opened this issue Dec 24, 2024 · 1 comment
Open

严重BUG 自己和自己聊天 #93

kwqseb opened this issue Dec 24, 2024 · 1 comment

Comments

@kwqseb
Copy link

kwqseb commented Dec 24, 2024

IMG_0519
IMG_0520
IMG_0521

如图 16:06分时别人发了重置会话 ,它突然转发给了自己
然后就开始重复自己对话 几个小时就烧光了40刀的API 并且触发了QQ的风控 被封了一天
第二天重新登陆 又出现这个情况 再次烧了10刀。。。
能否避免自己和自己发消息,QQ上面好像没办法把自己拉黑。

@kwqseb
Copy link
Author

kwqseb commented Dec 26, 2024

在com.ashin.handler 的QqMessageHandler.java下 更新以下代码 过滤自己和自己发消息

@EventHandler
public void onFriendMessageEvent(FriendMessageEvent event){
    // 检查消息发送者是否是机器人自身
    if (event.getSubject().getId() == event.getBot().getId()) {
        return; // 如果是机器人自己发的消息,直接返回,不处理
    }
    ChatBO chatBO = new ChatBO();
    chatBO.setSessionId(String.valueOf(event.getSubject().getId()));
    String prompt = event.getMessage().contentToString().trim();
    response(event, chatBO, prompt);
}

@EventHandler
public void onGroupMessageEvent(GroupMessageEvent event){
    // 检查消息发送者是否是机器人自身
    if (event.getSubject().getId() == event.getBot().getId()) {
        return; // 如果是机器人自己发的消息,直接返回,不处理
    }
    ChatBO chatBO = new ChatBO();
    chatBO.setSessionId(String.valueOf(event.getSubject().getId()));
    if (event.getMessage().contains(new At(event.getBot().getId()))) {
        String prompt = event.getMessage().contentToString().replace("@" + event.getBot().getId(), "").trim();
        response(event, chatBO, prompt);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant