package com.yaohun.mcbot.data;

import com.yaohun.mcbot.McBot;
import com.yaohun.mcbot.manage.WssReconnectManager;

public class BotGroup {

    private long groupId;

    public BotGroup(long groupId) {
        this.groupId = groupId;
    }

    public void sendMessage(String message){
        String escapedMessage = message
                .replace("\\", "\\\\")     // 转义反斜线
                .replace("\"", "\\\"")     // 转义引号
                .replace("\n", "\\n")      // 转义换行符
                .replace("\r", "\\r");     // 转义回车符（保险起见）

        String payload = String.format(
                "{\"action\":\"send_group_msg\",\"params\":{\"group_id\":%d,\"message\":\"%s\"}}",
                groupId, escapedMessage
        );
        WssReconnectManager.getClient().send(payload);
    }
}
