@Override
    public void doAlarm(List<AlarmMessage> alarmMessages) throws Exception {
        Map<String, SlackSettings> settingsMap = alarmRulesWatcher.getSlackSettings();
        if (settingsMap == null || settingsMap.isEmpty()) {
            return;
        }

        Map<String, List<AlarmMessage>> groupedMessages = groupMessagesByHook(alarmMessages);
        for (Map.Entry<String, List<AlarmMessage>> entry : groupedMessages.entrySet()) {
            var hookName = entry.getKey();
            var messages = entry.getValue();
            var setting = settingsMap.get(hookName);
            if (setting == null || CollectionUtils.isEmpty(setting.getWebhooks()) || CollectionUtils.isEmpty(
                messages)) {
                continue;
            }

            for (final var url : setting.getWebhooks()) {
                final var jsonObject = new JsonObject();
                final var jsonElements = new JsonArray();
                for (AlarmMessage item : messages) {
                    jsonElements.add(GSON.fromJson(
                        String.format(
                            setting.getTextTemplate(), item.getAlarmMessage()
                        ), JsonObject.class));
                }
                jsonObject.add("blocks", jsonElements);
                final var body = GSON.toJson(jsonObject);
                try {
                    post(URI.create(url), body, Map.of());
                } catch (Exception e) {
                    log.error("Failed to send alarm message to Slack: {}", url, e);
                }
            }
        }
    }
@Test
    public void testWechatWebhook() throws Exception {
        List<String> remoteEndpoints = new ArrayList<>();
        remoteEndpoints.add("http://127.0.0.1:" + SERVER.httpPort() + "/services/x/y/zssss");
        Rules rules = new Rules();
        String template = "{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\":alarm_clock: *Apache Skywalking Alarm* \\n **%s**.\"}}";
        SlackSettings setting1 = new SlackSettings("setting1", AlarmHooksType.slack, true);
        setting1.setWebhooks(remoteEndpoints);
        setting1.setTextTemplate(template);
        SlackSettings setting2 = new SlackSettings("setting2", AlarmHooksType.slack, false);
        setting2.setWebhooks(remoteEndpoints);
        setting2.setTextTemplate(template);
        rules.getSlackSettingsMap().put(setting1.getFormattedName(), setting1);
        rules.getSlackSettingsMap().put(setting2.getFormattedName(), setting2);
        AlarmRulesWatcher alarmRulesWatcher = new AlarmRulesWatcher(rules, null);
        SlackhookCallback slackhookCallback = new SlackhookCallback(alarmRulesWatcher);
        List<AlarmMessage> alarmMessages = new ArrayList<>(2);
        AlarmMessage alarmMessage = new AlarmMessage();
        alarmMessage.setScopeId(DefaultScopeDefine.SERVICE);
        alarmMessage.setRuleName("service_resp_time_rule");
        alarmMessage.setAlarmMessage("alarmMessage with [DefaultScopeDefine.All]");
        alarmMessage.getHooks().add(setting1.getFormattedName());
        alarmMessages.add(alarmMessage);
        AlarmMessage anotherAlarmMessage = new AlarmMessage();
        anotherAlarmMessage.setRuleName("service_resp_time_rule_2");
        anotherAlarmMessage.setScopeId(DefaultScopeDefine.ENDPOINT);
        anotherAlarmMessage.setAlarmMessage("anotherAlarmMessage with [DefaultScopeDefine.Endpoint]");
        anotherAlarmMessage.getHooks().add(setting2.getFormattedName());
        alarmMessages.add(anotherAlarmMessage);
        slackhookCallback.doAlarm(alarmMessages);
        Assertions.assertTrue(IS_SUCCESS.get());
    }