perf:脚本群机器人消息
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.xiang.xservice.glados.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-08-07 10:30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DingTalkScriptMsgService {
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
private static final String SECRET = "SEC768ed578c0fb31a9aec84b1c1db4f195f5aca203985bbb9d549e23e41c8874d1";
|
||||
private static final String TOKEN = "4709b708d961846e0aee523c5abc3b67e8fa424ee292501d85efd4e504f15a8b";
|
||||
private static final String USER_ID = "450841600726084717";
|
||||
|
||||
/**
|
||||
* 发送脚本消息
|
||||
* @param msg 消息
|
||||
*/
|
||||
public void sendScriptMsg(String msg) {
|
||||
try {
|
||||
dingTalkService.sendRobotMessage(SECRET, TOKEN, List.of(USER_ID), msg);
|
||||
} catch (Exception e) {
|
||||
log.error("信息发送异常, 信息:{}", msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,12 @@ package com.xiang.xservice.glados.service;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.glados.common.GladosConstants;
|
||||
import com.xiang.xservice.glados.common.URLConstants;
|
||||
import com.xiang.xservice.glados.entity.GladosRunLog;
|
||||
import com.xiang.xservice.xb.entity.pojo.User;
|
||||
import com.xiang.xservice.glados.entity.resp.GLaDOSResponse;
|
||||
import com.xiang.xservice.glados.repository.GladosMapper;
|
||||
import com.xiang.xservice.xb.entity.pojo.User;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -33,7 +32,7 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
|
||||
private final GladosMapper gladosMapper;
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkScriptMsgService dingTalkService;
|
||||
|
||||
@Value("${DingTalk.userList}")
|
||||
private String userList;
|
||||
@@ -84,7 +83,7 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
log.info("签到成功, 签到积分:{}, 签到消息:{}", gLaDOSResponse.getPoints(), gLaDOSResponse.getMessage());
|
||||
sb.append(user.getEmail()).append("签到成功,获得积分:").append(gLaDOSResponse.getPoints()).append("\n");
|
||||
try {
|
||||
dingTalkService.sendRobotMessage("[时间:" + LocalDateTime.now() + "] 用户: " +
|
||||
dingTalkService.sendScriptMsg("[时间:" + LocalDateTime.now() + "] 用户: " +
|
||||
user.getEmail() + "签到成功,获得积分:" + gLaDOSResponse.getPoints());
|
||||
} catch (Exception e) {
|
||||
log.error("发送钉钉消息失败", e);
|
||||
@@ -98,7 +97,7 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
log.warn("签到失败,用户:{}, cookie过期:{}", user.getEmail(), gLaDOSResponse.getMessage());
|
||||
String message = "[时间:" + LocalDateTime.now() + "] 用户: " + user.getEmail() + ",签到消息: " + gLaDOSResponse.getMessage();
|
||||
try {
|
||||
dingTalkService.sendRobotMessage(message);
|
||||
dingTalkService.sendScriptMsg(message);
|
||||
} catch (Exception e) {
|
||||
log.error("发送钉钉消息失败", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user