in xxljob-demo/xxljob-example-springboot/src/main/java/com/xxljob/executor/jobhandler/AIJob.java [94:113]
private ReturnT<String> sendMessage(OpenAIResponse openAIResponse) throws UnirestException {
ReturnT<String> rtn = ReturnT.SUCCESS;
Map<String, Object> map = new HashMap<>();
map.put("msgtype", "markdown");
Map<String, String> content = new HashMap<>();
content.put("title", "今日热点");
content.put("text", openAIResponse.getChoices().get(0).getMessage().getContent());
map.put("markdown", content);
HttpResponse<JsonNode> response = Unirest.post(webhook)
.header("Content-Type", "application/json")
.body(new Gson().toJson(map))
.asJson();
if (response.getStatus() != 200) {
rtn.setCode(ReturnT.FAIL_CODE);
rtn.setMsg("发送失败!");
return rtn;
}
return rtn;
}