package com.xiang.xservice.application.script.xb.service;

import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
import com.xiang.xservice.config.DingTalkRobotXbConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: xiang
 * @Date: 2025-08-07 11:02
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class DingTalkRobotService {
    private final DingTalkService dingTalkService;
    private final DingTalkRobotXbConfig dingTalkRobotConfig;

    /**
     * 发送脚本消息
     * @param msg   消息
     */
    public void sendXbMsg(String msg) {
        try {
            dingTalkService.sendRobotMessage(dingTalkRobotConfig.getSecret(), dingTalkRobotConfig.getToken(), dingTalkRobotConfig.getUsers(), msg);
        } catch (Exception e) {
            log.error("信息发送异常, 信息：{}", msg, e);
        }
    }
}
