-
Notifications
You must be signed in to change notification settings - Fork 77
Dinger 2.3 动态配置机器人
Jaemon edited this page Dec 26, 2020
·
1 revision
场景说明: 对于同一个消息体, 发送给钉钉机器人的同时也需要发送给企业微信机器人。
spring:
dinger:
project-id: ${spring.application.name}
# 默认使用钉钉
default-dinger: dingtalk
dingers:
# 使用钉钉机器人, 请根据自己机器人配置信息进行修改
dingtalk:
tokenId: 87dbeb7bc28894c3ycyl3d12457228ad309966275b5f427cd85f9025ebb520cf
secret: AEQ74a9039ai01f2ljm017b90ycye9asg6335f97c658ff37ff371ec8120581c7f09
# 使用企业微信机器人, 请根据自己机器人配置信息进行修改
wetalk:
token-id: 32865206-7082-46l5-8j39-2m7ycy6d868
@RestController
@Slf4j
public class DemoController {
@Autowired
private UserDinger userDinger;
@GetMapping("/send")
public Response send() {
// 发送给钉钉群
DingerResponse dingSuccess = userDinger.success("Jaemon");
log.info(objectMapper.writeValueAsString(dingSuccess));
// 动态配置企业微信机器人信息
DingerHelper.assignDinger(DingerType.WETALK, "32865206-7082-46l5-8j39-2m7ycy6d868", false);
// 发送给企业微信群
DingerResponse weSuccess = userDinger.success("Jaemon");
log.info(objectMapper.writeValueAsString(weSuccess));
return Repsonse.success();
}
}